Implements most of the remaining core standard functions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -71,6 +71,44 @@ TEST_CASE( "toint func works", "[integration]" ) {
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "tofloat func works", "[integration]" ) {
|
||||
Script* script = Script::Create(u"return tofloat('5.128')");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateFloat() == 5.128);
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "tostring func works", "[integration]" ) {
|
||||
Script* script = Script::Create(u"return tostring(5.128)");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateString() == u"5.128000");
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "type func works", "[integration]" ) {
|
||||
Script* script = Script::Create(u"return type(5.128)");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateString() == u"number");
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "isfloat returns true for floats", "[integration]" ) {
|
||||
Script* script = Script::Create(u"return isfloat(5.128)");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateBool());
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "isfloat returns false for integers", "[integration]" ) {
|
||||
Script* script = Script::Create(u"return isfloat(5)");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE_FALSE(result->EvaluateBool());
|
||||
delete script;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user