Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / test / sprtTests.cpp
diff options
context:
space:
mode:
1 files changed, 44 insertions, 0 deletions
-rw-r--r--JSImpl/test/sprtTests.cpp44
diff --git a/JSImpl/test/sprtTests.cpp b/JSImpl/test/sprtTests.cpp
index a7b9e3b..25b7665 100644
--- a/JSImpl/test/sprtTests.cpp
+++ b/JSImpl/test/sprtTests.cpp
@@ -379,3 +379,47 @@ TEST_F(SPASMTest, GCD)
CompileAndRun(program);
ASSERT_EQ(Output.str(), "3");
}
+
+TEST_F(SPASMTest, StringS)
+{
+ const char* program =
+ "push 1" "\n"
+ "string 1 'the answer is 42'" "\n"
+ "print 1" "\n"
+ ;
+ CompileAndRun(program);
+ ASSERT_EQ(Output.str(), "the answer is 42");
+}
+
+TEST_F(SPASMTest, StringD)
+{
+ const char* program =
+ "push 1" "\n"
+ "string 1 'the answer is 42'" "\n"
+ "print 1" "\n"
+ ;
+ CompileAndRun(program);
+ ASSERT_EQ(Output.str(), "the answer is 42");
+}
+
+TEST_F(SPASMTest, StringEscapeS)
+{
+ const char* program =
+ "push 1" "\n"
+ "string 1 'the answer\\' is 42'" "\n"
+ "print 1" "\n"
+ ;
+ CompileAndRun(program);
+ ASSERT_EQ(Output.str(), "the answer\\' is 42");
+}
+
+TEST_F(SPASMTest, StringEscapeD)
+{
+ const char* program =
+ "push 1" "\n"
+ "string 1 \"the answer\\\" is 42\"" "\n"
+ "print 1" "\n"
+ ;
+ CompileAndRun(program);
+ ASSERT_EQ(Output.str(), "the answer\\\" is 42");
+}