Implements exponent and modulus operators
This commit is contained in:
@@ -47,6 +47,22 @@ TEST_CASE( "Integer Division", "[integration]" ) {
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Integer Exponent", "[integration]" ) {
|
||||
auto script = Script::Create("return 9 ^ 3");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateFloat() == 729);
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Integer Modulus", "[integration]" ) {
|
||||
auto script = Script::Create("return 9 % 2");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateInteger() == 1);
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Float Addition", "[integration]" ) {
|
||||
auto script = Script::Create("1.2 + 5.34");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
@@ -75,4 +91,21 @@ TEST_CASE( "Float Division", "[integration]" ) {
|
||||
REQUIRE(result->EvaluateFloat() == Approx(10.7305524239));
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Float Exponent", "[integration]" ) {
|
||||
auto script = Script::Create("95.18 ^ 2.0");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateFloat() == Approx(9059.2324));
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Float Modulus", "[integration]" ) {
|
||||
auto script = Script::Create("return 9.2 % 2.0");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
REQUIRE(result->EvaluateFloat() == Approx(1.2));
|
||||
delete script;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user