summaryrefslogtreecommitdiffabout
path: root/test
Side-by-side diff
Diffstat (limited to 'test') (more/less context) (show whitespace changes)
-rw-r--r--test/.gitignore22
-rw-r--r--test/Makefile.am32
-rw-r--r--test/r01_closing_at_the_line_start.clichec16
-rw-r--r--test/r01_closing_at_the_line_start.expected8
-rw-r--r--test/r02_anchor_after_literal.clichec8
-rw-r--r--test/r02_anchor_after_literal.expected3
-rw-r--r--test/r03_percent_after_empty.clichec8
-rw-r--r--test/r03_percent_after_empty.expected6
-rw-r--r--test/r04_too_seamless_transitions.clichec9
-rw-r--r--test/r04_too_seamless_transitions.expected3
10 files changed, 115 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000..54191cb
--- a/dev/null
+++ b/test/.gitignore
@@ -0,0 +1,22 @@
+/test-suite.log
+
+/r01_closing_at_the_line_start
+/r01_closing_at_the_line_start.out
+/r01_closing_at_the_line_start.diff
+/r01_closing_at_the_line_start.check
+/r01_closing_at_the_line_start.log
+/r02_anchor_after_literal
+/r02_anchor_after_literal.out
+/r02_anchor_after_literal.diff
+/r02_anchor_after_literal.check
+/r02_anchor_after_literal.log
+/r03_percent_after_empty
+/r03_percent_after_empty.out
+/r03_percent_after_empty.diff
+/r03_percent_after_empty.check
+/r03_percent_after_empty.log
+/r04_too_seamless_transitions
+/r04_too_seamless_transitions.out
+/r04_too_seamless_transitions.diff
+/r04_too_seamless_transitions.check
+/r04_too_seamless_transitions.log
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..705278d
--- a/dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,32 @@
+TESTS=\
+ r01_closing_at_the_line_start.clichec \
+ r02_anchor_after_literal.clichec \
+ r03_percent_after_empty.clichec \
+ r04_too_seamless_transitions.clichec
+
+EXTRA_DIST=$(TESTS)
+CLEANFILES = $(basename $(TESTS)) \
+ $(foreach s,.out .diff,$(addsuffix $s,$(basename $(TESTS))))
+.INTERMEDIATE: $(CLEANFILES)
+
+TEST_EXTENSIONS=.clichec
+CLICHEC_LOG_COMPILER=test_clichec() { \
+ $(MAKE) "$$(basename $$1 .clichec)"{,.{out,diff,check}} ;\
+}; test_clichec
+
+gitignore: .gitignore
+.gitignore: Makefile
+ for t in ${TESTS} ; do for f in "$${t%.*}"{,.{out,diff,check,log}} ; do \
+ grep -q "^/$$f" .gitignore || echo "/$$f" >>.gitignore ;\
+ done done
+
+CLICHE=${top_builddir}/src/cliche
+SUFFIXES=.clichec .cc .out .diff .check
+.clichec.cc:
+ $(CLICHE) -C -o $@ $<
+%.out: %
+ ${builddir}/$< >$@
+%.diff: ${builddir}/%.out ${srcdir}/%.expected
+ @-diff -u "$*.expected" "$*.out" >"$@"
+%.check: %.diff
+ @test -s "$<" && { cat "$*.out";cp "$*.out" "$*.unexpected" ; exit 1 ; } || true
diff --git a/test/r01_closing_at_the_line_start.clichec b/test/r01_closing_at_the_line_start.clichec
new file mode 100644
index 0000000..11ebd8f
--- a/dev/null
+++ b/test/r01_closing_at_the_line_start.clichec
@@ -0,0 +1,16 @@
+#include <iostream>
+int main() {
+const char *t0 =
+<%literal>
+
+ test-literal
+
+</%literal>;
+std::cout << t0;
+
+<%output>
+
+ test-output
+
+</%output>
+}
diff --git a/test/r01_closing_at_the_line_start.expected b/test/r01_closing_at_the_line_start.expected
new file mode 100644
index 0000000..7854811
--- a/dev/null
+++ b/test/r01_closing_at_the_line_start.expected
@@ -0,0 +1,8 @@
+
+
+ test-literal
+
+
+
+ test-output
+
diff --git a/test/r02_anchor_after_literal.clichec b/test/r02_anchor_after_literal.clichec
new file mode 100644
index 0000000..c2049c0
--- a/dev/null
+++ b/test/r02_anchor_after_literal.clichec
@@ -0,0 +1,8 @@
+#include <iostream>
+int main() {
+const char *l3 = <%literal>line 3</%literal> ":"; int nl3 = __LINE__;
+std::cout << l3 << nl3 << std::endl;
+{<%output>line 5 (<% __LINE__ %>)</%output>}
+int l6 = __LINE__;
+std::cout << std::endl << "line 6: " << l6 << std::endl;
+};
diff --git a/test/r02_anchor_after_literal.expected b/test/r02_anchor_after_literal.expected
new file mode 100644
index 0000000..b53c949
--- a/dev/null
+++ b/test/r02_anchor_after_literal.expected
@@ -0,0 +1,3 @@
+line 3:3
+line 5 (5)
+line 6: 6
diff --git a/test/r03_percent_after_empty.clichec b/test/r03_percent_after_empty.clichec
new file mode 100644
index 0000000..62c82eb
--- a/dev/null
+++ b/test/r03_percent_after_empty.clichec
@@ -0,0 +1,8 @@
+#include <iostream>
+int main() {<%output>
+Test for broken handling of '^% ' line following the empty line.
+Like this:
+
+% std::cout << 1 << std::endl;
+
+</%output>}
diff --git a/test/r03_percent_after_empty.expected b/test/r03_percent_after_empty.expected
new file mode 100644
index 0000000..f2ee7b2
--- a/dev/null
+++ b/test/r03_percent_after_empty.expected
@@ -0,0 +1,6 @@
+
+Test for broken handling of '^% ' line following the empty line.
+Like this:
+
+1
+
diff --git a/test/r04_too_seamless_transitions.clichec b/test/r04_too_seamless_transitions.clichec
new file mode 100644
index 0000000..c313013
--- a/dev/null
+++ b/test/r04_too_seamless_transitions.clichec
@@ -0,0 +1,9 @@
+#include <iostream>
+int main() {
+int a=1,b=2;
+<%output>
+The transition like this - <% a %><% b %> should not glue 'ab' in the source together.
+Really.
+</%output>
+}
+
diff --git a/test/r04_too_seamless_transitions.expected b/test/r04_too_seamless_transitions.expected
new file mode 100644
index 0000000..2ab4e9f
--- a/dev/null
+++ b/test/r04_too_seamless_transitions.expected
@@ -0,0 +1,3 @@
+
+The transition like this - 12 should not glue 'ab' in the source together.
+Really.