summaryrefslogtreecommitdiff
path: root/Tests/AK/TestJSON.cpp
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-08-30 01:59:32 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-02 02:07:37 +0100
commit75ebcf6b4a710313d12dd1d350b0c1ff3d311b06 (patch)
treead110af8627dd3b72048938a70f4450d657bfc3c /Tests/AK/TestJSON.cpp
parent68c6161f250ae7c6cca8165ccd8a77f5426cbc05 (diff)
downloadserenity-75ebcf6b4a710313d12dd1d350b0c1ff3d311b06.zip
AK: Allow exponents in JSON double values
This is required for ECMA-404 compliance, but probably not for serenity itself.
Diffstat (limited to 'Tests/AK/TestJSON.cpp')
-rw-r--r--Tests/AK/TestJSON.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp
index ff887fe9d5..4634a9f5ee 100644
--- a/Tests/AK/TestJSON.cpp
+++ b/Tests/AK/TestJSON.cpp
@@ -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);
+}