Merge pull request #57620 from Haydoggo/expression-exp-fix

Fix Expression's parsing of positive exponent literals
This commit is contained in:
Rémi Verschelde 2022-02-05 10:14:10 +01:00 committed by GitHub
commit a0c87d4c11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 4 deletions

View File

@ -361,6 +361,7 @@ Error Expression::_get_token(Token &r_token) {
is_float = true;
} else if (c == 'e') {
reading = READING_EXP;
is_float = true;
} else {
reading = READING_DONE;
}
@ -397,9 +398,6 @@ Error Expression::_get_token(Token &r_token) {
exp_beg = true;
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
if (c == '-') {
is_float = true;
}
exp_sign = true;
} else {

View File

@ -137,7 +137,7 @@ TEST_CASE("[Expression] Scientific notation") {
expression.parse("2e5") == OK,
"The expression should parse successfully.");
CHECK_MESSAGE(
Math::is_equal_approx(double(expression.execute()), 25),
Math::is_equal_approx(double(expression.execute()), 2e5),
"The expression should return the expected result.");
CHECK_MESSAGE(