1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:27:35 +00:00

AK: Allow exponents in JSON double values

This is required for ECMA-404 compliance, but probably not for serenity
itself.
This commit is contained in:
davidot 2022-08-30 01:59:32 +02:00 committed by Linus Groh
parent 68c6161f25
commit 75ebcf6b4a
2 changed files with 55 additions and 8 deletions

View file

@ -134,3 +134,12 @@ TEST_CASE(json_parse_long_decimals)
auto value = JsonValue::from_string("1644452550.6489999294281"sv);
EXPECT_EQ(value.value().as_double(), 1644452550.6489999294281);
}
TEST_CASE(json_parse_number_with_exponent)
{
auto value_without_fraction = JsonValue::from_string("10e5"sv);
EXPECT_EQ(value_without_fraction.value().as_double(), 1000000.0);
auto value_with_fraction = JsonValue::from_string("10.5e5"sv);
EXPECT_EQ(value_with_fraction.value().as_double(), 1050000.0);
}