PorygonLang/tests/integration/IndexTests.cpp

29 lines
666 B
C++
Raw Normal View History

#ifdef TESTS_BUILD
#include <catch.hpp>
#include "../src/Script.hpp"
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