From 63de0fd33ccb7d227619db5ae6b1e292f5cd9ddb Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 13 Sep 2009 12:53:12 +0000 Subject: [PATCH] Add a couple more in-string eval unit tests to check for proper escaping --- include/chaiscript/language/chaiscript_parser.hpp | 4 ++-- unittests/instring_eval_more.chai | 4 ++++ unittests/instring_eval_more.txt | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 unittests/instring_eval_more.chai create mode 100644 unittests/instring_eval_more.txt diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 4528a41..69e6dc1 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -337,7 +337,7 @@ namespace chaiscript if (is_interpolated) { //If we've seen previous interpolation, add on instead of making a new one - TokenPtr plus(new Token("+", Token_Type::Str, filename, -1, -1, -1, -1)); + TokenPtr plus(new Token("+", Token_Type::Str, filename, prev_line, prev_col, line, col)); match_stack.push_back(plus); TokenPtr t(new Token(match, Token_Type::Quoted_String, filename, prev_line, prev_col, line, col)); @@ -437,7 +437,7 @@ namespace chaiscript } } if (is_interpolated) { - TokenPtr plus(new Token("+", Token_Type::Str, filename, -1, -1, -1, -1)); + TokenPtr plus(new Token("+", Token_Type::Str, filename, prev_line, prev_col, line, col)); match_stack.push_back(plus); TokenPtr t(new Token(match, Token_Type::Quoted_String, filename, prev_line, prev_col, line, col)); diff --git a/unittests/instring_eval_more.chai b/unittests/instring_eval_more.chai new file mode 100644 index 0000000..e07d11f --- /dev/null +++ b/unittests/instring_eval_more.chai @@ -0,0 +1,4 @@ +print("$ {4 + 5}") +print("$${4+5}") +print("Value: \${4 + 5}") +print("Value: \$${4 + 5}") diff --git a/unittests/instring_eval_more.txt b/unittests/instring_eval_more.txt new file mode 100644 index 0000000..5132bc7 --- /dev/null +++ b/unittests/instring_eval_more.txt @@ -0,0 +1,4 @@ +$ {4 + 5} +$9 +Value: ${4 + 5} +Value: $9