From 72d9bbcc3154142af79fb686d9dc7e4d1fa1badb Mon Sep 17 00:00:00 2001 From: dtrendafilov Date: Thu, 29 Nov 2018 09:13:12 +0200 Subject: Feature/strings (#75) * The assembler supports string opcode * disabled the string test until implmented * strings can be printed --- JSImpl/test/sprtTests.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'JSImpl/test/sprtTests.cpp') 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"); +} -- cgit v1.3.1-23-gd82d