PorygonLang/tests/integration/StringOperationsTests.cpp

38 lines
995 B
C++
Raw Normal View History

#ifdef TESTS_BUILD
#include <catch.hpp>
#include "../src/Script.hpp"
using namespace Porygon;
TEST_CASE( "Simple String", "[integration]" ) {
2019-05-28 15:49:03 +00:00
auto script = Script::Create("\"foo bar\"");
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto lastValue = script->GetLastValue();
REQUIRE(lastValue->EvaluateString() == u"foo bar");
2019-05-29 12:58:00 +00:00
delete script;
}
TEST_CASE( "String Concat", "[integration]" ) {
auto script = Script::Create(R"("foo" + "bar")");
2019-05-28 15:49:03 +00:00
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto lastValue = script->GetLastValue();
REQUIRE(lastValue->EvaluateString() == u"foobar");
delete script;
}
TEST_CASE( "String Concat 2", "[integration]" ) {
auto script = Script::Create("'foo' + 'bar'");
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto lastValue = script->GetLastValue();
REQUIRE(lastValue->EvaluateString() == u"foobar");
2019-05-29 12:58:00 +00:00
delete script;
}
#endif