From e5cc27d43efe0cf432824128e940dd6c49a42915 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 24 May 2019 15:33:13 +0200 Subject: [PATCH] Fix literal floats evaluating wrong values --- src/Evaluator/Evaluator.cpp | 2 +- tests/integration/numerical_operations_tests.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Evaluator/Evaluator.cpp b/src/Evaluator/Evaluator.cpp index d270e51..1eda38f 100644 --- a/src/Evaluator/Evaluator.cpp +++ b/src/Evaluator/Evaluator.cpp @@ -76,7 +76,7 @@ double Evaluator::EvaluateFloatExpression(BoundExpression *expression) { throw EvaluationException("Can't evaluate expression as integer, it will return an integer, not a float."); } switch (expression->GetKind()){ - case BoundExpressionKind ::LiteralFloat: return ((BoundLiteralIntegerExpression*)expression)->GetValue(); + case BoundExpressionKind ::LiteralFloat: return ((BoundLiteralFloatExpression*)expression)->GetValue(); case BoundExpressionKind ::Binary: return this -> EvaluateFloatBinary((BoundBinaryExpression*)expression); case BoundExpressionKind ::LiteralInteger: diff --git a/tests/integration/numerical_operations_tests.cpp b/tests/integration/numerical_operations_tests.cpp index 472d80f..48609c0 100644 --- a/tests/integration/numerical_operations_tests.cpp +++ b/tests/integration/numerical_operations_tests.cpp @@ -57,6 +57,6 @@ TEST_CASE( "Float Division", "[integration]" ) { REQUIRE(!script.Diagnostics -> HasErrors()); script.Evaluate(); auto lastValue = script.GetLastValue(); - REQUIRE(*any_cast(lastValue) == Approx(10.730)); + REQUIRE(*any_cast(lastValue) == Approx(10.7305524239)); } #endif