Implements exponent and modulus operators

This commit is contained in:
2019-09-22 17:38:17 +02:00
parent de39464b33
commit 30d82085cc
9 changed files with 92 additions and 4 deletions

View File

@@ -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