Fix literal floats evaluating wrong values

This commit is contained in:
Deukhoofd 2019-05-24 15:33:13 +02:00
parent e648013e1d
commit e5cc27d43e
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
2 changed files with 2 additions and 2 deletions

View File

@ -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."); throw EvaluationException("Can't evaluate expression as integer, it will return an integer, not a float.");
} }
switch (expression->GetKind()){ 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 ::Binary: return this -> EvaluateFloatBinary((BoundBinaryExpression*)expression);
case BoundExpressionKind ::LiteralInteger: case BoundExpressionKind ::LiteralInteger:

View File

@ -57,6 +57,6 @@ TEST_CASE( "Float Division", "[integration]" ) {
REQUIRE(!script.Diagnostics -> HasErrors()); REQUIRE(!script.Diagnostics -> HasErrors());
script.Evaluate(); script.Evaluate();
auto lastValue = script.GetLastValue(); auto lastValue = script.GetLastValue();
REQUIRE(*any_cast<double>(lastValue) == Approx(10.730)); REQUIRE(*any_cast<double>(lastValue) == Approx(10.7305524239));
} }
#endif #endif