2019-05-25 14:15:20 +00:00
|
|
|
|
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
#include <catch.hpp>
|
|
|
|
#include "../src/Script.hpp"
|
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
using namespace Porygon;
|
2019-05-25 14:15:20 +00:00
|
|
|
|
|
|
|
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();
|
2019-06-15 15:20:27 +00:00
|
|
|
REQUIRE(*lastValue->EvaluateString() == u"foo bar");
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 14:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "String Concat", "[integration]" ) {
|
2019-06-05 15:46:46 +00:00
|
|
|
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();
|
2019-06-15 15:20:27 +00:00
|
|
|
REQUIRE(*lastValue->EvaluateString() == u"foobar");
|
2019-06-05 15:46:46 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "String Concat 2", "[integration]" ) {
|
|
|
|
auto script = Script::Create("'foo' + 'bar'");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
|
|
script->Evaluate();
|
|
|
|
auto lastValue = script->GetLastValue();
|
2019-06-15 15:20:27 +00:00
|
|
|
REQUIRE(*lastValue->EvaluateString() == u"foobar");
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 14:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|