1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 17:17:45 +00:00

AK+GMLCompiler: Remove JsonValue::as_double()

Replace its single (non-test) usage with newly created as_number(),
which does not leak information about internal integer storage type.
This commit is contained in:
Dan Klishch 2023-11-14 00:49:41 -05:00 committed by Andrew Kaster
parent 5230d2af91
commit faef802229
3 changed files with 27 additions and 13 deletions

View file

@ -133,16 +133,16 @@ TEST_CASE(json_parse_empty_string)
TEST_CASE(json_parse_long_decimals)
{
auto value = JsonValue::from_string("1644452550.6489999294281"sv);
EXPECT_EQ(value.value().as_double(), 1644452550.6489999294281);
EXPECT_EQ(value.value().to_number<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);
EXPECT_EQ(value_without_fraction.value().to_number<double>(), 1000000.0);
auto value_with_fraction = JsonValue::from_string("10.5e5"sv);
EXPECT_EQ(value_with_fraction.value().as_double(), 1050000.0);
EXPECT_EQ(value_with_fraction.value().to_number<double>(), 1050000.0);
}
TEST_CASE(json_parse_special_numbers)