From eebf5cb885f266104333ac145355ef6e2599e5f6 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Fri, 25 Oct 2013 21:43:37 +0200 Subject: New Test --- stupid_template_engine.php | 2 +- tests/test_escapes/.gitignore | 3 +++ tests/test_escapes/code.php | 7 +++++++ tests/test_escapes/test.tpl | 7 +++++++ tests/test_escapes/want | 7 +++++++ 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/test_escapes/.gitignore create mode 100644 tests/test_escapes/code.php create mode 100644 tests/test_escapes/test.tpl create mode 100644 tests/test_escapes/want diff --git a/stupid_template_engine.php b/stupid_template_engine.php index cfb5882..dd90a89 100644 --- a/stupid_template_engine.php +++ b/stupid_template_engine.php @@ -196,7 +196,7 @@ class Parser { $off = $this->off; $name = $this->take_while(function($c) { return ctype_alnum($c) || ($c == "_"); }); if(mb_strlen($name) == 0) { - throw new ParseCompileError("Expected a name (alphanumeric chars + '_', at least one char)"); + throw new ParseCompileError("Expected a name (alphanumeric chars + '_', at least one char)", $this->name, $off); } return $name; } diff --git a/tests/test_escapes/.gitignore b/tests/test_escapes/.gitignore new file mode 100644 index 0000000..de2a41b --- /dev/null +++ b/tests/test_escapes/.gitignore @@ -0,0 +1,3 @@ +have +*.ast +*.transc.php diff --git a/tests/test_escapes/code.php b/tests/test_escapes/code.php new file mode 100644 index 0000000..05984d1 --- /dev/null +++ b/tests/test_escapes/code.php @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..5458fde --- /dev/null +++ b/tests/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/test_escapes/want b/tests/test_escapes/want new file mode 100644 index 0000000..3278c4d --- /dev/null +++ b/tests/test_escapes/want @@ -0,0 +1,7 @@ +\\\$foo +${bar} +?{foo|bar|baz} +Bar|Baz +foo\"bar$ +' +\' -- cgit v1.2.3-70-g09d2