Fix literal floats evaluating wrong values
This commit is contained in:
parent
e648013e1d
commit
e5cc27d43e
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue