From 7ae08e3c35760fd7c5cb00d9a8a27488090f952d Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 23 Oct 2013 15:22:12 +0200 Subject: Added some tests. Many of these break. Mostly because the way whitespace/newlines are added (or not added). This is terribly broken ATM... (It was okay with the old parser, I'll try to replicate that behaviour) --- tests/run_all.sh | 6 +++--- tests/test_array/.gitignore | 3 +++ tests/test_array/code.php | 13 +++++++++++++ tests/test_array/test.tpl | 1 + tests/test_array/want | 1 + tests/test_blocks/.gitignore | 3 +++ tests/test_blocks/code.php | 5 +++++ tests/test_blocks/master.tpl | 3 +++ tests/test_blocks/test.tpl | 2 ++ tests/test_blocks/want | 3 +++ tests/test_mktag/.gitignore | 3 +++ tests/test_mktag/code.php | 5 +++++ tests/test_mktag/test.tpl | 12 ++++++++++++ tests/test_mktag/want | 1 + tests/test_pseudotags/.gitignore | 3 +++ tests/test_pseudotags/code.php | 5 +++++ tests/test_pseudotags/test.tpl | 2 ++ tests/test_pseudotags/want | 2 ++ tests/test_short/.gitignore | 3 +++ tests/test_short/code.php | 5 +++++ tests/test_short/comment | 1 + tests/test_short/test.tpl | 1 + tests/test_short/want | 1 + 23 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 tests/test_array/.gitignore create mode 100644 tests/test_array/code.php create mode 100644 tests/test_array/test.tpl create mode 100644 tests/test_array/want create mode 100644 tests/test_blocks/.gitignore create mode 100644 tests/test_blocks/code.php create mode 100644 tests/test_blocks/master.tpl create mode 100644 tests/test_blocks/test.tpl create mode 100644 tests/test_blocks/want create mode 100644 tests/test_mktag/.gitignore create mode 100644 tests/test_mktag/code.php create mode 100644 tests/test_mktag/test.tpl create mode 100644 tests/test_mktag/want create mode 100644 tests/test_pseudotags/.gitignore create mode 100644 tests/test_pseudotags/code.php create mode 100644 tests/test_pseudotags/test.tpl create mode 100644 tests/test_pseudotags/want create mode 100644 tests/test_short/.gitignore create mode 100644 tests/test_short/code.php create mode 100644 tests/test_short/comment create mode 100644 tests/test_short/test.tpl create mode 100644 tests/test_short/want (limited to 'tests') diff --git a/tests/run_all.sh b/tests/run_all.sh index 75909d1..486454b 100755 --- a/tests/run_all.sh +++ b/tests/run_all.sh @@ -4,8 +4,8 @@ r=0 for t in test_*; do cd $t php ../test.php > have - echo -n "$t: " - if cmp want have; then + echo -ne "\e[1m$t\e[0m: " + if cmp -s want have; then echo "OK" rm *.transc.php else @@ -18,4 +18,4 @@ for t in test_*; do cd .. done -exit $r \ No newline at end of file +exit $r diff --git a/tests/test_array/.gitignore b/tests/test_array/.gitignore new file mode 100644 index 0000000..de2a41b --- /dev/null +++ b/tests/test_array/.gitignore @@ -0,0 +1,3 @@ +have +*.ast +*.transc.php diff --git a/tests/test_array/code.php b/tests/test_array/code.php new file mode 100644 index 0000000..58601e2 --- /dev/null +++ b/tests/test_array/code.php @@ -0,0 +1,13 @@ +vars["foo"] = array( + "a" => array( + "blabla" => "OK" + ), + "b" => "bla" + ); + $ste->vars["bar"] = array( + "baz" => "a" + ); +} diff --git a/tests/test_array/test.tpl b/tests/test_array/test.tpl new file mode 100644 index 0000000..050045d --- /dev/null +++ b/tests/test_array/test.tpl @@ -0,0 +1 @@ +${foo[$bar[baz]][${foo[b]}bla]} \ No newline at end of file diff --git a/tests/test_array/want b/tests/test_array/want new file mode 100644 index 0000000..a0aba93 --- /dev/null +++ b/tests/test_array/want @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/tests/test_blocks/.gitignore b/tests/test_blocks/.gitignore new file mode 100644 index 0000000..de2a41b --- /dev/null +++ b/tests/test_blocks/.gitignore @@ -0,0 +1,3 @@ +have +*.ast +*.transc.php diff --git a/tests/test_blocks/code.php b/tests/test_blocks/code.php new file mode 100644 index 0000000..de8c553 --- /dev/null +++ b/tests/test_blocks/code.php @@ -0,0 +1,5 @@ +Bar +Baz \ No newline at end of file diff --git a/tests/test_blocks/test.tpl b/tests/test_blocks/test.tpl new file mode 100644 index 0000000..44c6891 --- /dev/null +++ b/tests/test_blocks/test.tpl @@ -0,0 +1,2 @@ + +Replaced \ No newline at end of file diff --git a/tests/test_blocks/want b/tests/test_blocks/want new file mode 100644 index 0000000..b9d1515 --- /dev/null +++ b/tests/test_blocks/want @@ -0,0 +1,3 @@ +Foo +Replaced +Baz \ No newline at end of file diff --git a/tests/test_mktag/.gitignore b/tests/test_mktag/.gitignore new file mode 100644 index 0000000..de2a41b --- /dev/null +++ b/tests/test_mktag/.gitignore @@ -0,0 +1,3 @@ +have +*.ast +*.transc.php diff --git a/tests/test_mktag/code.php b/tests/test_mktag/code.php new file mode 100644 index 0000000..de8c553 --- /dev/null +++ b/tests/test_mktag/code.php @@ -0,0 +1,5 @@ +2 * + + $_tag_parameters[b]Ugly hack, since STE does no scoping... + + + $i + $i + $b + + + + \ No newline at end of file diff --git a/tests/test_mktag/want b/tests/test_mktag/want new file mode 100644 index 0000000..be0b204 --- /dev/null +++ b/tests/test_mktag/want @@ -0,0 +1 @@ +0-4-8-12-16-20 \ No newline at end of file diff --git a/tests/test_pseudotags/.gitignore b/tests/test_pseudotags/.gitignore new file mode 100644 index 0000000..de2a41b --- /dev/null +++ b/tests/test_pseudotags/.gitignore @@ -0,0 +1,3 @@ +have +*.ast +*.transc.php diff --git a/tests/test_pseudotags/code.php b/tests/test_pseudotags/code.php new file mode 100644 index 0000000..de8c553 --- /dev/null +++ b/tests/test_pseudotags/code.php @@ -0,0 +1,5 @@ +Ignore $meFoo +$foo bar \ No newline at end of file diff --git a/tests/test_pseudotags/want b/tests/test_pseudotags/want new file mode 100644 index 0000000..4cd4538 --- /dev/null +++ b/tests/test_pseudotags/want @@ -0,0 +1,2 @@ + +$foo bar \ No newline at end of file diff --git a/tests/test_short/.gitignore b/tests/test_short/.gitignore new file mode 100644 index 0000000..de2a41b --- /dev/null +++ b/tests/test_short/.gitignore @@ -0,0 +1,3 @@ +have +*.ast +*.transc.php diff --git a/tests/test_short/code.php b/tests/test_short/code.php new file mode 100644 index 0000000..de8c553 --- /dev/null +++ b/tests/test_short/code.php @@ -0,0 +1,5 @@ +