mirror of
https://github.com/godotengine/godot.git
synced 2025-10-25 18:54:43 +00:00
Make parser treat all exponent literals as float
This commit is contained in:
parent
29c4644890
commit
1305ff92f7
2 changed files with 2 additions and 4 deletions
|
|
@ -373,6 +373,7 @@ Error Expression::_get_token(Token &r_token) {
|
||||||
is_float = true;
|
is_float = true;
|
||||||
} else if (c == 'e') {
|
} else if (c == 'e') {
|
||||||
reading = READING_EXP;
|
reading = READING_EXP;
|
||||||
|
is_float = true;
|
||||||
} else {
|
} else {
|
||||||
reading = READING_DONE;
|
reading = READING_DONE;
|
||||||
}
|
}
|
||||||
|
|
@ -409,9 +410,6 @@ Error Expression::_get_token(Token &r_token) {
|
||||||
exp_beg = true;
|
exp_beg = true;
|
||||||
|
|
||||||
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
|
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
|
||||||
if (c == '-') {
|
|
||||||
is_float = true;
|
|
||||||
}
|
|
||||||
exp_sign = true;
|
exp_sign = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ TEST_CASE("[Expression] Scientific notation") {
|
||||||
expression.parse("2e5") == OK,
|
expression.parse("2e5") == OK,
|
||||||
"The expression should parse successfully.");
|
"The expression should parse successfully.");
|
||||||
CHECK_MESSAGE(
|
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.");
|
"The expression should return the expected result.");
|
||||||
|
|
||||||
CHECK_MESSAGE(
|
CHECK_MESSAGE(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue