2019-06-06 15:35:51 +00:00
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
#include <catch.hpp>
|
|
|
|
#include "../src/Script.hpp"
|
2019-06-17 16:35:12 +00:00
|
|
|
using namespace Porygon;
|
2019-06-06 15:35:51 +00:00
|
|
|
|
|
|
|
TEST_CASE( "String indexing", "[integration]" ) {
|
|
|
|
auto script = Script::Create("'foobar'[4]");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
|
|
script->Evaluate();
|
|
|
|
auto lastValue = script->GetLastValue();
|
2019-06-23 13:58:14 +00:00
|
|
|
REQUIRE(lastValue->EvaluateString() == u"b");
|
2019-06-06 15:35:51 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
2019-06-17 13:45:33 +00:00
|
|
|
TEST_CASE( "Identifier Index", "[integration]" ) {
|
|
|
|
auto script = Script::Create(uR"(
|
|
|
|
foo = {
|
|
|
|
bar = "test"
|
|
|
|
}
|
|
|
|
return foo.bar
|
|
|
|
)");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
|
|
auto result = script->Evaluate();
|
2019-06-23 13:58:14 +00:00
|
|
|
REQUIRE(result->EvaluateString() == u"test");
|
2019-06-17 13:45:33 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-06 15:35:51 +00:00
|
|
|
#endif
|