30 lines
691 B
C++
30 lines
691 B
C++
#ifdef TESTS_BUILD
|
|
#include <catch.hpp>
|
|
#include "../src/Script.hpp"
|
|
using namespace Porygon;
|
|
|
|
TEST_CASE( "String indexing", "[integration]" ) {
|
|
auto script = Script::Create("'foobar'[4]");
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
script->Evaluate();
|
|
auto lastValue = script->GetLastValue();
|
|
REQUIRE(*lastValue->EvaluateString() == u"b");
|
|
delete script;
|
|
}
|
|
|
|
TEST_CASE( "Identifier Index", "[integration]" ) {
|
|
auto script = Script::Create(uR"(
|
|
foo = {
|
|
bar = "test"
|
|
}
|
|
return foo.bar
|
|
)");
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
auto result = script->Evaluate();
|
|
REQUIRE(*result->EvaluateString() == u"test");
|
|
delete script;
|
|
}
|
|
|
|
|
|
#endif
|