From 4e2bfed23c17929795f2082d6e77937170caeaa9 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Sun, 13 Sep 2020 21:35:16 +0200 Subject: Turn our functional tests into PhpUnit tests --- tests/dump_ast.php | 6 --- tests/functional/.gitignore | 1 + tests/functional/BaseTest.php | 55 ++++++++++++++++++++++ tests/functional/TestStorage.php | 32 +++++++++++++ tests/functional/test_array/Test.php | 27 +++++++++++ tests/functional/test_array/test.tpl | 1 + tests/functional/test_array/want | 1 + tests/functional/test_blocks/Test.php | 18 +++++++ tests/functional/test_blocks/main.tpl | 3 ++ tests/functional/test_blocks/test.tpl | 2 + tests/functional/test_blocks/want | 3 ++ tests/functional/test_closure/Test.php | 18 +++++++ tests/functional/test_closure/test.tpl | 10 ++++ tests/functional/test_closure/want | 2 + tests/functional/test_escapes/Test.php | 21 +++++++++ tests/functional/test_escapes/test.tpl | 7 +++ tests/functional/test_escapes/want | 7 +++ tests/functional/test_foreach/Test.php | 23 +++++++++ tests/functional/test_foreach/test.tpl | 8 ++++ tests/functional/test_foreach/want | 5 ++ tests/functional/test_getset/Test.php | 19 ++++++++ tests/functional/test_getset/test.tpl | 5 ++ tests/functional/test_getset/want | 4 ++ tests/functional/test_loop/Test.php | 18 +++++++ tests/functional/test_loop/test.tpl | 3 ++ tests/functional/test_loop/want | 11 +++++ tests/functional/test_mktag/Test.php | 18 +++++++ tests/functional/test_mktag/test.tpl | 11 +++++ tests/functional/test_mktag/want | 11 +++++ tests/functional/test_pseudotags/Test.php | 18 +++++++ tests/functional/test_pseudotags/test.tpl | 2 + tests/functional/test_pseudotags/want | 1 + tests/functional/test_recursive/Test.php | 19 ++++++++ tests/functional/test_recursive/test.tpl | 11 +++++ tests/functional/test_recursive/want | 1 + tests/functional/test_scoping/Test.php | 18 +++++++ tests/functional/test_scoping/test.tpl | 18 +++++++ tests/functional/test_scoping/want | 9 ++++ tests/functional/test_short/Test.php | 18 +++++++ tests/functional/test_short/test.tpl | 1 + tests/functional/test_short/want | 1 + .../test_short_for_additional_attribs/Test.php | 23 +++++++++ .../test_short_for_additional_attribs/test.tpl | 5 ++ .../test_short_for_additional_attribs/want | 5 ++ tests/functional/test_simple/Test.php | 19 ++++++++ tests/functional/test_simple/test.tpl | 1 + tests/functional/test_simple/want | 1 + .../test_static_numeric_array_access/Test.php | 23 +++++++++ .../test_static_numeric_array_access/test.tpl | 3 ++ .../test_static_numeric_array_access/want | 3 ++ tests/functional/test_tagname/Test.php | 33 +++++++++++++ tests/functional/test_tagname/test.tpl | 4 ++ tests/functional/test_tagname/want | 4 ++ .../test_trailing_closing_array_bracket/Test.php | 23 +++++++++ .../test_trailing_closing_array_bracket/test.tpl | 3 ++ .../test_trailing_closing_array_bracket/want | 3 ++ tests/mktest.sh | 18 ------- tests/run_tests.sh | 42 ----------------- tests/test.php | 29 ------------ tests/test_array/.gitignore | 3 -- tests/test_array/code.php | 14 ------ 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_closure/.gitignore | 3 -- tests/test_closure/code.php | 5 -- tests/test_closure/test.tpl | 10 ---- tests/test_closure/want | 2 - tests/test_escapes/.gitignore | 3 -- tests/test_escapes/code.php | 8 ---- tests/test_escapes/test.tpl | 7 --- tests/test_escapes/want | 7 --- tests/test_foreach/.gitignore | 3 -- tests/test_foreach/code.php | 10 ---- tests/test_foreach/test.tpl | 8 ---- tests/test_foreach/want | 5 -- tests/test_getset/.gitignore | 3 -- tests/test_getset/code.php | 6 --- tests/test_getset/test.tpl | 5 -- tests/test_getset/want | 4 -- tests/test_loop/.gitignore | 3 -- tests/test_loop/code.php | 5 -- tests/test_loop/test.tpl | 3 -- tests/test_loop/want | 11 ----- tests/test_mktag/.gitignore | 3 -- tests/test_mktag/code.php | 5 -- tests/test_mktag/test.tpl | 11 ----- tests/test_mktag/want | 11 ----- tests/test_pseudotags/.gitignore | 3 -- tests/test_pseudotags/code.php | 5 -- tests/test_pseudotags/test.tpl | 2 - tests/test_pseudotags/want | 1 - tests/test_recursive/.gitignore | 3 -- tests/test_recursive/code.php | 6 --- tests/test_recursive/test.tpl | 11 ----- tests/test_recursive/want | 1 - tests/test_scoping/.gitignore | 3 -- tests/test_scoping/code.php | 5 -- tests/test_scoping/test.tpl | 18 ------- tests/test_scoping/want | 9 ---- tests/test_short/.gitignore | 3 -- tests/test_short/code.php | 5 -- tests/test_short/test.tpl | 1 - tests/test_short/want | 1 - tests/test_short_for_additional_attribs/.gitignore | 3 -- tests/test_short_for_additional_attribs/code.php | 12 ----- tests/test_short_for_additional_attribs/test.tpl | 5 -- tests/test_short_for_additional_attribs/want | 5 -- tests/test_simple/.gitignore | 3 -- tests/test_simple/code.php | 6 --- tests/test_simple/test.tpl | 1 - tests/test_simple/want | 1 - tests/test_static_numeric_array_access/.gitignore | 3 -- tests/test_static_numeric_array_access/code.php | 12 ----- tests/test_static_numeric_array_access/test.tpl | 3 -- tests/test_static_numeric_array_access/want | 3 -- tests/test_tagname/.gitignore | 3 -- tests/test_tagname/code.php | 22 --------- tests/test_tagname/test.tpl | 4 -- tests/test_tagname/want | 4 -- .../test_trailing_closing_array_bracket/.gitignore | 3 -- tests/test_trailing_closing_array_bracket/code.php | 12 ----- tests/test_trailing_closing_array_bracket/test.tpl | 3 -- tests/test_trailing_closing_array_bracket/want | 3 -- 128 files changed, 614 insertions(+), 459 deletions(-) delete mode 100644 tests/dump_ast.php create mode 100644 tests/functional/.gitignore create mode 100644 tests/functional/BaseTest.php create mode 100644 tests/functional/TestStorage.php create mode 100644 tests/functional/test_array/Test.php create mode 100644 tests/functional/test_array/test.tpl create mode 100644 tests/functional/test_array/want create mode 100644 tests/functional/test_blocks/Test.php create mode 100644 tests/functional/test_blocks/main.tpl create mode 100644 tests/functional/test_blocks/test.tpl create mode 100644 tests/functional/test_blocks/want create mode 100644 tests/functional/test_closure/Test.php create mode 100644 tests/functional/test_closure/test.tpl create mode 100644 tests/functional/test_closure/want create mode 100644 tests/functional/test_escapes/Test.php create mode 100644 tests/functional/test_escapes/test.tpl create mode 100644 tests/functional/test_escapes/want create mode 100644 tests/functional/test_foreach/Test.php create mode 100644 tests/functional/test_foreach/test.tpl create mode 100644 tests/functional/test_foreach/want create mode 100644 tests/functional/test_getset/Test.php create mode 100644 tests/functional/test_getset/test.tpl create mode 100644 tests/functional/test_getset/want create mode 100644 tests/functional/test_loop/Test.php create mode 100644 tests/functional/test_loop/test.tpl create mode 100644 tests/functional/test_loop/want create mode 100644 tests/functional/test_mktag/Test.php create mode 100644 tests/functional/test_mktag/test.tpl create mode 100644 tests/functional/test_mktag/want create mode 100644 tests/functional/test_pseudotags/Test.php create mode 100644 tests/functional/test_pseudotags/test.tpl create mode 100644 tests/functional/test_pseudotags/want create mode 100644 tests/functional/test_recursive/Test.php create mode 100644 tests/functional/test_recursive/test.tpl create mode 100644 tests/functional/test_recursive/want create mode 100644 tests/functional/test_scoping/Test.php create mode 100644 tests/functional/test_scoping/test.tpl create mode 100644 tests/functional/test_scoping/want create mode 100644 tests/functional/test_short/Test.php create mode 100644 tests/functional/test_short/test.tpl create mode 100644 tests/functional/test_short/want create mode 100644 tests/functional/test_short_for_additional_attribs/Test.php create mode 100644 tests/functional/test_short_for_additional_attribs/test.tpl create mode 100644 tests/functional/test_short_for_additional_attribs/want create mode 100644 tests/functional/test_simple/Test.php create mode 100644 tests/functional/test_simple/test.tpl create mode 100644 tests/functional/test_simple/want create mode 100644 tests/functional/test_static_numeric_array_access/Test.php create mode 100644 tests/functional/test_static_numeric_array_access/test.tpl create mode 100644 tests/functional/test_static_numeric_array_access/want create mode 100644 tests/functional/test_tagname/Test.php create mode 100644 tests/functional/test_tagname/test.tpl create mode 100644 tests/functional/test_tagname/want create mode 100644 tests/functional/test_trailing_closing_array_bracket/Test.php create mode 100644 tests/functional/test_trailing_closing_array_bracket/test.tpl create mode 100644 tests/functional/test_trailing_closing_array_bracket/want delete mode 100755 tests/mktest.sh delete mode 100755 tests/run_tests.sh delete mode 100644 tests/test.php delete mode 100644 tests/test_array/.gitignore delete mode 100644 tests/test_array/code.php delete mode 100644 tests/test_array/test.tpl delete mode 100644 tests/test_array/want delete mode 100644 tests/test_blocks/.gitignore delete mode 100644 tests/test_blocks/code.php delete mode 100644 tests/test_blocks/master.tpl delete mode 100644 tests/test_blocks/test.tpl delete mode 100644 tests/test_blocks/want delete mode 100644 tests/test_closure/.gitignore delete mode 100644 tests/test_closure/code.php delete mode 100644 tests/test_closure/test.tpl delete mode 100644 tests/test_closure/want delete mode 100644 tests/test_escapes/.gitignore delete mode 100644 tests/test_escapes/code.php delete mode 100644 tests/test_escapes/test.tpl delete mode 100644 tests/test_escapes/want delete mode 100644 tests/test_foreach/.gitignore delete mode 100644 tests/test_foreach/code.php delete mode 100644 tests/test_foreach/test.tpl delete mode 100644 tests/test_foreach/want delete mode 100644 tests/test_getset/.gitignore delete mode 100644 tests/test_getset/code.php delete mode 100644 tests/test_getset/test.tpl delete mode 100644 tests/test_getset/want delete mode 100644 tests/test_loop/.gitignore delete mode 100644 tests/test_loop/code.php delete mode 100644 tests/test_loop/test.tpl delete mode 100644 tests/test_loop/want delete mode 100644 tests/test_mktag/.gitignore delete mode 100644 tests/test_mktag/code.php delete mode 100644 tests/test_mktag/test.tpl delete mode 100644 tests/test_mktag/want delete mode 100644 tests/test_pseudotags/.gitignore delete mode 100644 tests/test_pseudotags/code.php delete mode 100644 tests/test_pseudotags/test.tpl delete mode 100644 tests/test_pseudotags/want delete mode 100644 tests/test_recursive/.gitignore delete mode 100644 tests/test_recursive/code.php delete mode 100644 tests/test_recursive/test.tpl delete mode 100644 tests/test_recursive/want delete mode 100644 tests/test_scoping/.gitignore delete mode 100644 tests/test_scoping/code.php delete mode 100644 tests/test_scoping/test.tpl delete mode 100644 tests/test_scoping/want delete mode 100644 tests/test_short/.gitignore delete mode 100644 tests/test_short/code.php delete mode 100644 tests/test_short/test.tpl delete mode 100644 tests/test_short/want delete mode 100644 tests/test_short_for_additional_attribs/.gitignore delete mode 100644 tests/test_short_for_additional_attribs/code.php delete mode 100644 tests/test_short_for_additional_attribs/test.tpl delete mode 100644 tests/test_short_for_additional_attribs/want delete mode 100644 tests/test_simple/.gitignore delete mode 100644 tests/test_simple/code.php delete mode 100644 tests/test_simple/test.tpl delete mode 100644 tests/test_simple/want delete mode 100644 tests/test_static_numeric_array_access/.gitignore delete mode 100644 tests/test_static_numeric_array_access/code.php delete mode 100644 tests/test_static_numeric_array_access/test.tpl delete mode 100644 tests/test_static_numeric_array_access/want delete mode 100644 tests/test_tagname/.gitignore delete mode 100644 tests/test_tagname/code.php delete mode 100644 tests/test_tagname/test.tpl delete mode 100644 tests/test_tagname/want delete mode 100644 tests/test_trailing_closing_array_bracket/.gitignore delete mode 100644 tests/test_trailing_closing_array_bracket/code.php delete mode 100644 tests/test_trailing_closing_array_bracket/test.tpl delete mode 100644 tests/test_trailing_closing_array_bracket/want (limited to 'tests') diff --git a/tests/dump_ast.php b/tests/dump_ast.php deleted file mode 100644 index 70a15af..0000000 --- a/tests/dump_ast.php +++ /dev/null @@ -1,6 +0,0 @@ -ste = new STECore(new TestStorage($this->getDirectory())); + $this->ste->mute_runtime_errors = false; + + $this->setUpSte($this->ste); + } + + protected function setUpSte(STECore $ste): void + { + } + + public function testTemplate(): void + { + $have = $this->ste->exectemplate("test.tpl"); + $want = file_get_contents($this->getDirectory() . DIRECTORY_SEPARATOR . "want"); + + $normalizedHave = self::normalize($have); + $normalizedWant = self::normalize($want); + + self::assertSame($normalizedWant, $normalizedHave); + } + + /** + * Get the directory of the test. + * @return string + */ + abstract protected function getDirectory(): string; +} diff --git a/tests/functional/TestStorage.php b/tests/functional/TestStorage.php new file mode 100644 index 0000000..2403668 --- /dev/null +++ b/tests/functional/TestStorage.php @@ -0,0 +1,32 @@ +dir = $dir; + } + + public function load($tpl, &$mode) + { + $mode = StorageAccess::MODE_SOURCE; + return file_get_contents($this->dir . DIRECTORY_SEPARATOR . $tpl); + } + + public function save($tpl, $data, $mode) + { + if ($mode != StorageAccess::MODE_TRANSCOMPILED) { + return; + } + + file_put_contents($this->dir . DIRECTORY_SEPARATOR . "$tpl.transc.php", $data); + } +} diff --git a/tests/functional/test_array/Test.php b/tests/functional/test_array/Test.php new file mode 100644 index 0000000..58f0cb8 --- /dev/null +++ b/tests/functional/test_array/Test.php @@ -0,0 +1,27 @@ +vars["foo"] = array( + "a" => array( + "blabla" => "OK" + ), + "b" => "bla" + ); + $ste->vars["bar"] = array( + "baz" => "a" + ); + } +} diff --git a/tests/functional/test_array/test.tpl b/tests/functional/test_array/test.tpl new file mode 100644 index 0000000..050045d --- /dev/null +++ b/tests/functional/test_array/test.tpl @@ -0,0 +1 @@ +${foo[$bar[baz]][${foo[b]}bla]} \ No newline at end of file diff --git a/tests/functional/test_array/want b/tests/functional/test_array/want new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/tests/functional/test_array/want @@ -0,0 +1 @@ +OK diff --git a/tests/functional/test_blocks/Test.php b/tests/functional/test_blocks/Test.php new file mode 100644 index 0000000..05e8e09 --- /dev/null +++ b/tests/functional/test_blocks/Test.php @@ -0,0 +1,18 @@ +Bar +Baz \ No newline at end of file diff --git a/tests/functional/test_blocks/test.tpl b/tests/functional/test_blocks/test.tpl new file mode 100644 index 0000000..3d14e46 --- /dev/null +++ b/tests/functional/test_blocks/test.tpl @@ -0,0 +1,2 @@ + +Replaced \ No newline at end of file diff --git a/tests/functional/test_blocks/want b/tests/functional/test_blocks/want new file mode 100644 index 0000000..640cfef --- /dev/null +++ b/tests/functional/test_blocks/want @@ -0,0 +1,3 @@ +Foo +Replaced +Baz diff --git a/tests/functional/test_closure/Test.php b/tests/functional/test_closure/Test.php new file mode 100644 index 0000000..012e4c6 --- /dev/null +++ b/tests/functional/test_closure/Test.php @@ -0,0 +1,18 @@ + + + + $x + + + +10 +20 +30 +40 \ No newline at end of file diff --git a/tests/functional/test_closure/want b/tests/functional/test_closure/want new file mode 100644 index 0000000..98d2f20 --- /dev/null +++ b/tests/functional/test_closure/want @@ -0,0 +1,2 @@ +40 +60 diff --git a/tests/functional/test_escapes/Test.php b/tests/functional/test_escapes/Test.php new file mode 100644 index 0000000..5c2a2ab --- /dev/null +++ b/tests/functional/test_escapes/Test.php @@ -0,0 +1,21 @@ +register_tag("my_echo", function ($ste, $params, $sub) { + return $params["text"]; + }); + } +} diff --git a/tests/functional/test_escapes/test.tpl b/tests/functional/test_escapes/test.tpl new file mode 100644 index 0000000..5458fde --- /dev/null +++ b/tests/functional/test_escapes/test.tpl @@ -0,0 +1,7 @@ +\\\\\\\$foo +\${bar} +\?{foo|bar|baz} +?{|Foo|Bar\|Baz} + + +\' \ No newline at end of file diff --git a/tests/functional/test_escapes/want b/tests/functional/test_escapes/want new file mode 100644 index 0000000..3278c4d --- /dev/null +++ b/tests/functional/test_escapes/want @@ -0,0 +1,7 @@ +\\\$foo +${bar} +?{foo|bar|baz} +Bar|Baz +foo\"bar$ +' +\' diff --git a/tests/functional/test_foreach/Test.php b/tests/functional/test_foreach/Test.php new file mode 100644 index 0000000..3f8cc73 --- /dev/null +++ b/tests/functional/test_foreach/Test.php @@ -0,0 +1,23 @@ +vars["foo"] = array( + "a" => array("a" => 100, "b" => 200), + "b" => array("a" => 1, "b" => 2), + "c" => array("a" => 42, "b" => 1337) + ); + } +} diff --git a/tests/functional/test_foreach/test.tpl b/tests/functional/test_foreach/test.tpl new file mode 100644 index 0000000..1aec8b4 --- /dev/null +++ b/tests/functional/test_foreach/test.tpl @@ -0,0 +1,8 @@ + + $i: $k -> $v[a], $v[b] + +--- + + $v + --empty-- + diff --git a/tests/functional/test_foreach/want b/tests/functional/test_foreach/want new file mode 100644 index 0000000..5710bf7 --- /dev/null +++ b/tests/functional/test_foreach/want @@ -0,0 +1,5 @@ +0: a -> 100, 200 +1: b -> 1, 2 +2: c -> 42, 1337 +--- +--empty-- diff --git a/tests/functional/test_getset/Test.php b/tests/functional/test_getset/Test.php new file mode 100644 index 0000000..6f34500 --- /dev/null +++ b/tests/functional/test_getset/Test.php @@ -0,0 +1,19 @@ +vars["foo"] = "bar"; + } +} diff --git a/tests/functional/test_getset/test.tpl b/tests/functional/test_getset/test.tpl new file mode 100644 index 0000000..06f865a --- /dev/null +++ b/tests/functional/test_getset/test.tpl @@ -0,0 +1,5 @@ +\$foo = $foo +\$foo = +baz +\$foo = $foo +\$foo = diff --git a/tests/functional/test_getset/want b/tests/functional/test_getset/want new file mode 100644 index 0000000..567c753 --- /dev/null +++ b/tests/functional/test_getset/want @@ -0,0 +1,4 @@ +$foo = bar +$foo = bar +$foo = baz +$foo = baz diff --git a/tests/functional/test_loop/Test.php b/tests/functional/test_loop/Test.php new file mode 100644 index 0000000..05a76d7 --- /dev/null +++ b/tests/functional/test_loop/Test.php @@ -0,0 +1,18 @@ + +$i + \ No newline at end of file diff --git a/tests/functional/test_loop/want b/tests/functional/test_loop/want new file mode 100644 index 0000000..30b148d --- /dev/null +++ b/tests/functional/test_loop/want @@ -0,0 +1,11 @@ +10 +9 +8 +7 +6 +5 +4 +3 +2 +1 +0 diff --git a/tests/functional/test_mktag/Test.php b/tests/functional/test_mktag/Test.php new file mode 100644 index 0000000..c850509 --- /dev/null +++ b/tests/functional/test_mktag/Test.php @@ -0,0 +1,18 @@ +2 * + + + + $i + $i + $_tag_parameters[b] + + + + \ No newline at end of file diff --git a/tests/functional/test_mktag/want b/tests/functional/test_mktag/want new file mode 100644 index 0000000..3e2351c --- /dev/null +++ b/tests/functional/test_mktag/want @@ -0,0 +1,11 @@ +0 +- +4 +- +8 +- +12 +- +16 +- +20 diff --git a/tests/functional/test_pseudotags/Test.php b/tests/functional/test_pseudotags/Test.php new file mode 100644 index 0000000..f64ff5f --- /dev/null +++ b/tests/functional/test_pseudotags/Test.php @@ -0,0 +1,18 @@ +Ignore $meFoo +$foo bar \ No newline at end of file diff --git a/tests/functional/test_pseudotags/want b/tests/functional/test_pseudotags/want new file mode 100644 index 0000000..3aaffdc --- /dev/null +++ b/tests/functional/test_pseudotags/want @@ -0,0 +1 @@ +$foo bar diff --git a/tests/functional/test_recursive/Test.php b/tests/functional/test_recursive/Test.php new file mode 100644 index 0000000..d393791 --- /dev/null +++ b/tests/functional/test_recursive/Test.php @@ -0,0 +1,19 @@ +mute_runtime_errors = false; + } +} diff --git a/tests/functional/test_recursive/test.tpl b/tests/functional/test_recursive/test.tpl new file mode 100644 index 0000000..bea3934 --- /dev/null +++ b/tests/functional/test_recursive/test.tpl @@ -0,0 +1,11 @@ + + + ~{$_tag_parameters[n]|eq|0} + 1 + + $_tag_parameters[n] - 1 + * $_tag_parameters[n] + + + + \ No newline at end of file diff --git a/tests/functional/test_recursive/want b/tests/functional/test_recursive/want new file mode 100644 index 0000000..3fbd4a8 --- /dev/null +++ b/tests/functional/test_recursive/want @@ -0,0 +1 @@ +3628800 diff --git a/tests/functional/test_scoping/Test.php b/tests/functional/test_scoping/Test.php new file mode 100644 index 0000000..b15f911 --- /dev/null +++ b/tests/functional/test_scoping/Test.php @@ -0,0 +1,18 @@ +A +B + + in foo: \$a = $a + in foo: \$b = $b + in foo: \$c = $c + X + Y + Z + in foo (after set): \$a = $a + in foo (after set): \$b = $b + in foo (after set): \$c = $c + + + +\$a = $a +\$b = $b +\$c = $c \ No newline at end of file diff --git a/tests/functional/test_scoping/want b/tests/functional/test_scoping/want new file mode 100644 index 0000000..6e7a154 --- /dev/null +++ b/tests/functional/test_scoping/want @@ -0,0 +1,9 @@ +in foo: $a = A +in foo: $b = B +in foo: $c = +in foo (after set): $a = X +in foo (after set): $b = Y +in foo (after set): $c = Z +$a = X +$b = B +$c = diff --git a/tests/functional/test_short/Test.php b/tests/functional/test_short/Test.php new file mode 100644 index 0000000..2b138f5 --- /dev/null +++ b/tests/functional/test_short/Test.php @@ -0,0 +1,18 @@ +set_var_by_name("data", array( + array('content' => 'foo', 'foo' => true), + array('content' => 'bar', 'foo' => false), + array('content' => 'baz', 'foo' => false), + )); + } +} diff --git a/tests/functional/test_short_for_additional_attribs/test.tpl b/tests/functional/test_short_for_additional_attribs/test.tpl new file mode 100644 index 0000000..e6b30e4 --- /dev/null +++ b/tests/functional/test_short_for_additional_attribs/test.tpl @@ -0,0 +1,5 @@ +
    + + $x[content] + +
\ No newline at end of file diff --git a/tests/functional/test_short_for_additional_attribs/want b/tests/functional/test_short_for_additional_attribs/want new file mode 100644 index 0000000..c46d63f --- /dev/null +++ b/tests/functional/test_short_for_additional_attribs/want @@ -0,0 +1,5 @@ +
    +
  • foo
  • +
  • bar
  • +
  • baz
  • +
diff --git a/tests/functional/test_simple/Test.php b/tests/functional/test_simple/Test.php new file mode 100644 index 0000000..e2b58d9 --- /dev/null +++ b/tests/functional/test_simple/Test.php @@ -0,0 +1,19 @@ +vars["foo"] = "World"; + } +} diff --git a/tests/functional/test_simple/test.tpl b/tests/functional/test_simple/test.tpl new file mode 100644 index 0000000..30a4f22 --- /dev/null +++ b/tests/functional/test_simple/test.tpl @@ -0,0 +1 @@ +Hello $foo! \ No newline at end of file diff --git a/tests/functional/test_simple/want b/tests/functional/test_simple/want new file mode 100644 index 0000000..980a0d5 --- /dev/null +++ b/tests/functional/test_simple/want @@ -0,0 +1 @@ +Hello World! diff --git a/tests/functional/test_static_numeric_array_access/Test.php b/tests/functional/test_static_numeric_array_access/Test.php new file mode 100644 index 0000000..0c6a853 --- /dev/null +++ b/tests/functional/test_static_numeric_array_access/Test.php @@ -0,0 +1,23 @@ +set_var_by_name("foo", array( + "foo", + "bar", + "baz", + )); + } +} diff --git a/tests/functional/test_static_numeric_array_access/test.tpl b/tests/functional/test_static_numeric_array_access/test.tpl new file mode 100644 index 0000000..a313c6b --- /dev/null +++ b/tests/functional/test_static_numeric_array_access/test.tpl @@ -0,0 +1,3 @@ +$foo[0] +$foo[1] +$foo[2] diff --git a/tests/functional/test_static_numeric_array_access/want b/tests/functional/test_static_numeric_array_access/want new file mode 100644 index 0000000..86e041d --- /dev/null +++ b/tests/functional/test_static_numeric_array_access/want @@ -0,0 +1,3 @@ +foo +bar +baz diff --git a/tests/functional/test_tagname/Test.php b/tests/functional/test_tagname/Test.php new file mode 100644 index 0000000..8e3d8f6 --- /dev/null +++ b/tests/functional/test_tagname/Test.php @@ -0,0 +1,33 @@ +register_tag( + $name, + function ($ste, $params, $sub) use ($name) { + return $name; + } + ); + } + } +} diff --git a/tests/functional/test_tagname/test.tpl b/tests/functional/test_tagname/test.tpl new file mode 100644 index 0000000..30ca889 --- /dev/null +++ b/tests/functional/test_tagname/test.tpl @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/functional/test_tagname/want b/tests/functional/test_tagname/want new file mode 100644 index 0000000..3233294 --- /dev/null +++ b/tests/functional/test_tagname/want @@ -0,0 +1,4 @@ +foo +ab_cd +foo123baz +x0123 diff --git a/tests/functional/test_trailing_closing_array_bracket/Test.php b/tests/functional/test_trailing_closing_array_bracket/Test.php new file mode 100644 index 0000000..9e6ff2c --- /dev/null +++ b/tests/functional/test_trailing_closing_array_bracket/Test.php @@ -0,0 +1,23 @@ +set_var_by_name("foo", array( + "foo", + "bar", + "baz", + )); + } +} diff --git a/tests/functional/test_trailing_closing_array_bracket/test.tpl b/tests/functional/test_trailing_closing_array_bracket/test.tpl new file mode 100644 index 0000000..68f6caa --- /dev/null +++ b/tests/functional/test_trailing_closing_array_bracket/test.tpl @@ -0,0 +1,3 @@ +$foo[0] +$foo[1] +$foo[2] \ No newline at end of file diff --git a/tests/functional/test_trailing_closing_array_bracket/want b/tests/functional/test_trailing_closing_array_bracket/want new file mode 100644 index 0000000..86e041d --- /dev/null +++ b/tests/functional/test_trailing_closing_array_bracket/want @@ -0,0 +1,3 @@ +foo +bar +baz diff --git a/tests/mktest.sh b/tests/mktest.sh deleted file mode 100755 index 126aebc..0000000 --- a/tests/mktest.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -mkdir "$1" -touch "$1/test.tpl" -touch "$1/want" - -echo ' "$1/code.php" - -echo 'have -*.ast -*.transc.php' > "$1/.gitignore" diff --git a/tests/run_tests.sh b/tests/run_tests.sh deleted file mode 100755 index 4e46977..0000000 --- a/tests/run_tests.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -set -e - -run() { - ( # So we don't have to cd .. - cd "$1" || return 1 - - php ../test.php > have - - printf '\e[1m%s\e[0m: ' "$1" - if sed 's/\s*//' < have | grep -v '^$' | cmp -s want; then - echo "OK" - rm ./*.transc.php - else - echo "FAILED" - for tpl in *.tpl; do - php ../dump_ast.php < "$tpl" > "$tpl.ast" - done - return 1 - fi - ) -} - -run_many() { - retval=0 - while [ $# -gt 0 ]; do - if ! run "$1"; then - retval=1 - fi - - shift - done - - return $retval -} - -if [ $# -eq 0 ]; then - run_many test_* -else - run_many "$@" -fi diff --git a/tests/test.php b/tests/test.php deleted file mode 100644 index 15453b0..0000000 --- a/tests/test.php +++ /dev/null @@ -1,29 +0,0 @@ -mute_runtime_errors = false; -test_func($ste); -echo $ste->exectemplate("test.tpl"); diff --git a/tests/test_array/.gitignore b/tests/test_array/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_array/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_array/code.php b/tests/test_array/code.php deleted file mode 100644 index b524c15..0000000 --- a/tests/test_array/code.php +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 050045d..0000000 --- a/tests/test_array/test.tpl +++ /dev/null @@ -1 +0,0 @@ -${foo[$bar[baz]][${foo[b]}bla]} \ No newline at end of file diff --git a/tests/test_array/want b/tests/test_array/want deleted file mode 100644 index d86bac9..0000000 --- a/tests/test_array/want +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/tests/test_blocks/.gitignore b/tests/test_blocks/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_blocks/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_blocks/code.php b/tests/test_blocks/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_blocks/code.php +++ /dev/null @@ -1,5 +0,0 @@ -Bar -Baz \ No newline at end of file diff --git a/tests/test_blocks/test.tpl b/tests/test_blocks/test.tpl deleted file mode 100644 index 44c6891..0000000 --- a/tests/test_blocks/test.tpl +++ /dev/null @@ -1,2 +0,0 @@ - -Replaced \ No newline at end of file diff --git a/tests/test_blocks/want b/tests/test_blocks/want deleted file mode 100644 index 640cfef..0000000 --- a/tests/test_blocks/want +++ /dev/null @@ -1,3 +0,0 @@ -Foo -Replaced -Baz diff --git a/tests/test_closure/.gitignore b/tests/test_closure/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_closure/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_closure/code.php b/tests/test_closure/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_closure/code.php +++ /dev/null @@ -1,5 +0,0 @@ - - - - $x + - - -10 -20 -30 -40 \ No newline at end of file diff --git a/tests/test_closure/want b/tests/test_closure/want deleted file mode 100644 index 98d2f20..0000000 --- a/tests/test_closure/want +++ /dev/null @@ -1,2 +0,0 @@ -40 -60 diff --git a/tests/test_escapes/.gitignore b/tests/test_escapes/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_escapes/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_escapes/code.php b/tests/test_escapes/code.php deleted file mode 100644 index a1904c8..0000000 --- a/tests/test_escapes/code.php +++ /dev/null @@ -1,8 +0,0 @@ -register_tag("my_echo", function ($ste, $params, $sub) { - return $params["text"]; - }); -} diff --git a/tests/test_escapes/test.tpl b/tests/test_escapes/test.tpl deleted file mode 100644 index 5458fde..0000000 --- a/tests/test_escapes/test.tpl +++ /dev/null @@ -1,7 +0,0 @@ -\\\\\\\$foo -\${bar} -\?{foo|bar|baz} -?{|Foo|Bar\|Baz} - - -\' \ No newline at end of file diff --git a/tests/test_escapes/want b/tests/test_escapes/want deleted file mode 100644 index 3278c4d..0000000 --- a/tests/test_escapes/want +++ /dev/null @@ -1,7 +0,0 @@ -\\\$foo -${bar} -?{foo|bar|baz} -Bar|Baz -foo\"bar$ -' -\' diff --git a/tests/test_foreach/.gitignore b/tests/test_foreach/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_foreach/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_foreach/code.php b/tests/test_foreach/code.php deleted file mode 100644 index 60ad311..0000000 --- a/tests/test_foreach/code.php +++ /dev/null @@ -1,10 +0,0 @@ -vars["foo"] = array( - "a" => array("a" => 100, "b" => 200), - "b" => array("a" => 1, "b" => 2), - "c" => array("a" => 42, "b" => 1337) - ); -} diff --git a/tests/test_foreach/test.tpl b/tests/test_foreach/test.tpl deleted file mode 100644 index 1aec8b4..0000000 --- a/tests/test_foreach/test.tpl +++ /dev/null @@ -1,8 +0,0 @@ - - $i: $k -> $v[a], $v[b] - ---- - - $v - --empty-- - diff --git a/tests/test_foreach/want b/tests/test_foreach/want deleted file mode 100644 index 5710bf7..0000000 --- a/tests/test_foreach/want +++ /dev/null @@ -1,5 +0,0 @@ -0: a -> 100, 200 -1: b -> 1, 2 -2: c -> 42, 1337 ---- ---empty-- diff --git a/tests/test_getset/.gitignore b/tests/test_getset/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_getset/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_getset/code.php b/tests/test_getset/code.php deleted file mode 100644 index 722af1e..0000000 --- a/tests/test_getset/code.php +++ /dev/null @@ -1,6 +0,0 @@ -vars["foo"] = "bar"; -} diff --git a/tests/test_getset/test.tpl b/tests/test_getset/test.tpl deleted file mode 100644 index 06f865a..0000000 --- a/tests/test_getset/test.tpl +++ /dev/null @@ -1,5 +0,0 @@ -\$foo = $foo -\$foo = -baz -\$foo = $foo -\$foo = diff --git a/tests/test_getset/want b/tests/test_getset/want deleted file mode 100644 index 567c753..0000000 --- a/tests/test_getset/want +++ /dev/null @@ -1,4 +0,0 @@ -$foo = bar -$foo = bar -$foo = baz -$foo = baz diff --git a/tests/test_loop/.gitignore b/tests/test_loop/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_loop/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_loop/code.php b/tests/test_loop/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_loop/code.php +++ /dev/null @@ -1,5 +0,0 @@ - -$i - \ No newline at end of file diff --git a/tests/test_loop/want b/tests/test_loop/want deleted file mode 100644 index 30b148d..0000000 --- a/tests/test_loop/want +++ /dev/null @@ -1,11 +0,0 @@ -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 -0 diff --git a/tests/test_mktag/.gitignore b/tests/test_mktag/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_mktag/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_mktag/code.php b/tests/test_mktag/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_mktag/code.php +++ /dev/null @@ -1,5 +0,0 @@ -2 * - - - - $i - $i - $_tag_parameters[b] - - - - \ No newline at end of file diff --git a/tests/test_mktag/want b/tests/test_mktag/want deleted file mode 100644 index 3e2351c..0000000 --- a/tests/test_mktag/want +++ /dev/null @@ -1,11 +0,0 @@ -0 -- -4 -- -8 -- -12 -- -16 -- -20 diff --git a/tests/test_pseudotags/.gitignore b/tests/test_pseudotags/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_pseudotags/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_pseudotags/code.php b/tests/test_pseudotags/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_pseudotags/code.php +++ /dev/null @@ -1,5 +0,0 @@ -Ignore $meFoo -$foo bar \ No newline at end of file diff --git a/tests/test_pseudotags/want b/tests/test_pseudotags/want deleted file mode 100644 index 3aaffdc..0000000 --- a/tests/test_pseudotags/want +++ /dev/null @@ -1 +0,0 @@ -$foo bar diff --git a/tests/test_recursive/.gitignore b/tests/test_recursive/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_recursive/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_recursive/code.php b/tests/test_recursive/code.php deleted file mode 100644 index 96b967b..0000000 --- a/tests/test_recursive/code.php +++ /dev/null @@ -1,6 +0,0 @@ -mute_runtime_errors = false; -} diff --git a/tests/test_recursive/test.tpl b/tests/test_recursive/test.tpl deleted file mode 100644 index bea3934..0000000 --- a/tests/test_recursive/test.tpl +++ /dev/null @@ -1,11 +0,0 @@ - - - ~{$_tag_parameters[n]|eq|0} - 1 - - $_tag_parameters[n] - 1 - * $_tag_parameters[n] - - - - \ No newline at end of file diff --git a/tests/test_recursive/want b/tests/test_recursive/want deleted file mode 100644 index 3fbd4a8..0000000 --- a/tests/test_recursive/want +++ /dev/null @@ -1 +0,0 @@ -3628800 diff --git a/tests/test_scoping/.gitignore b/tests/test_scoping/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_scoping/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_scoping/code.php b/tests/test_scoping/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_scoping/code.php +++ /dev/null @@ -1,5 +0,0 @@ -A -B - - in foo: \$a = $a - in foo: \$b = $b - in foo: \$c = $c - X - Y - Z - in foo (after set): \$a = $a - in foo (after set): \$b = $b - in foo (after set): \$c = $c - - - -\$a = $a -\$b = $b -\$c = $c \ No newline at end of file diff --git a/tests/test_scoping/want b/tests/test_scoping/want deleted file mode 100644 index 6e7a154..0000000 --- a/tests/test_scoping/want +++ /dev/null @@ -1,9 +0,0 @@ -in foo: $a = A -in foo: $b = B -in foo: $c = -in foo (after set): $a = X -in foo (after set): $b = Y -in foo (after set): $c = Z -$a = X -$b = B -$c = diff --git a/tests/test_short/.gitignore b/tests/test_short/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_short/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_short/code.php b/tests/test_short/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_short/code.php +++ /dev/null @@ -1,5 +0,0 @@ -set_var_by_name("data", array( - array('content' => 'foo', 'foo' => true), - array('content' => 'bar', 'foo' => false), - array('content' => 'baz', 'foo' => false), - )); -} diff --git a/tests/test_short_for_additional_attribs/test.tpl b/tests/test_short_for_additional_attribs/test.tpl deleted file mode 100644 index e6b30e4..0000000 --- a/tests/test_short_for_additional_attribs/test.tpl +++ /dev/null @@ -1,5 +0,0 @@ -
    - - $x[content] - -
\ No newline at end of file diff --git a/tests/test_short_for_additional_attribs/want b/tests/test_short_for_additional_attribs/want deleted file mode 100644 index c46d63f..0000000 --- a/tests/test_short_for_additional_attribs/want +++ /dev/null @@ -1,5 +0,0 @@ -
    -
  • foo
  • -
  • bar
  • -
  • baz
  • -
diff --git a/tests/test_simple/.gitignore b/tests/test_simple/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_simple/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_simple/code.php b/tests/test_simple/code.php deleted file mode 100644 index 2712e2b..0000000 --- a/tests/test_simple/code.php +++ /dev/null @@ -1,6 +0,0 @@ -vars["foo"] = "World"; -} diff --git a/tests/test_simple/test.tpl b/tests/test_simple/test.tpl deleted file mode 100644 index 30a4f22..0000000 --- a/tests/test_simple/test.tpl +++ /dev/null @@ -1 +0,0 @@ -Hello $foo! \ No newline at end of file diff --git a/tests/test_simple/want b/tests/test_simple/want deleted file mode 100644 index 980a0d5..0000000 --- a/tests/test_simple/want +++ /dev/null @@ -1 +0,0 @@ -Hello World! diff --git a/tests/test_static_numeric_array_access/.gitignore b/tests/test_static_numeric_array_access/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_static_numeric_array_access/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_static_numeric_array_access/code.php b/tests/test_static_numeric_array_access/code.php deleted file mode 100644 index 77f48be..0000000 --- a/tests/test_static_numeric_array_access/code.php +++ /dev/null @@ -1,12 +0,0 @@ -set_var_by_name("foo", array( - "foo", - "bar", - "baz", - )); -} diff --git a/tests/test_static_numeric_array_access/test.tpl b/tests/test_static_numeric_array_access/test.tpl deleted file mode 100644 index a313c6b..0000000 --- a/tests/test_static_numeric_array_access/test.tpl +++ /dev/null @@ -1,3 +0,0 @@ -$foo[0] -$foo[1] -$foo[2] diff --git a/tests/test_static_numeric_array_access/want b/tests/test_static_numeric_array_access/want deleted file mode 100644 index 86e041d..0000000 --- a/tests/test_static_numeric_array_access/want +++ /dev/null @@ -1,3 +0,0 @@ -foo -bar -baz diff --git a/tests/test_tagname/.gitignore b/tests/test_tagname/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_tagname/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_tagname/code.php b/tests/test_tagname/code.php deleted file mode 100644 index e934989..0000000 --- a/tests/test_tagname/code.php +++ /dev/null @@ -1,22 +0,0 @@ -register_tag( - $name, - function ($ste, $params, $sub) use ($name) { - return $name; - } - ); - } -} diff --git a/tests/test_tagname/test.tpl b/tests/test_tagname/test.tpl deleted file mode 100644 index 30ca889..0000000 --- a/tests/test_tagname/test.tpl +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/tests/test_tagname/want b/tests/test_tagname/want deleted file mode 100644 index 3233294..0000000 --- a/tests/test_tagname/want +++ /dev/null @@ -1,4 +0,0 @@ -foo -ab_cd -foo123baz -x0123 diff --git a/tests/test_trailing_closing_array_bracket/.gitignore b/tests/test_trailing_closing_array_bracket/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_trailing_closing_array_bracket/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_trailing_closing_array_bracket/code.php b/tests/test_trailing_closing_array_bracket/code.php deleted file mode 100644 index 77f48be..0000000 --- a/tests/test_trailing_closing_array_bracket/code.php +++ /dev/null @@ -1,12 +0,0 @@ -set_var_by_name("foo", array( - "foo", - "bar", - "baz", - )); -} diff --git a/tests/test_trailing_closing_array_bracket/test.tpl b/tests/test_trailing_closing_array_bracket/test.tpl deleted file mode 100644 index 68f6caa..0000000 --- a/tests/test_trailing_closing_array_bracket/test.tpl +++ /dev/null @@ -1,3 +0,0 @@ -$foo[0] -$foo[1] -$foo[2] \ No newline at end of file diff --git a/tests/test_trailing_closing_array_bracket/want b/tests/test_trailing_closing_array_bracket/want deleted file mode 100644 index 86e041d..0000000 --- a/tests/test_trailing_closing_array_bracket/want +++ /dev/null @@ -1,3 +0,0 @@ -foo -bar -baz -- cgit v1.2.3-54-g00ecf