Commit b6695f0542

Marc Tiehuis <marc@tiehu.is>
2024-03-09 05:03:05
std.json: update tests to match new floating point formatting
1 parent 04fd113
Changed files (2)
lib/std/json/dynamic_test.zig
@@ -213,7 +213,7 @@ test "Value.jsonStringify" {
         \\ true,
         \\ 42,
         \\ 43,
-        \\ 4.2e+01,
+        \\ 4.2e1,
         \\ "weeee",
         \\ [
         \\  1,
lib/std/json/stringify_test.zig
@@ -74,16 +74,16 @@ fn testBasicWriteStream(w: anytype, slice_stream: anytype) !void {
         \\{
         \\  "object": {
         \\    "one": 1,
-        \\    "two": 2.0e+00
+        \\    "two": 2e0
         \\  },
         \\  "string": "This is a string",
         \\  "array": [
         \\    "Another string",
         \\    1,
-        \\    3.5e+00
+        \\    3.5e0
         \\  ],
         \\  "int": 10,
-        \\  "float": 3.5e+00
+        \\  "float": 3.5e0
         \\}
     ;
     try std.testing.expectEqualStrings(expected, result);
@@ -123,12 +123,12 @@ test "stringify basic types" {
     try testStringify("null", @as(?u8, null), .{});
     try testStringify("null", @as(?*u32, null), .{});
     try testStringify("42", 42, .{});
-    try testStringify("4.2e+01", 42.0, .{});
+    try testStringify("4.2e1", 42.0, .{});
     try testStringify("42", @as(u8, 42), .{});
     try testStringify("42", @as(u128, 42), .{});
     try testStringify("9999999999999999", 9999999999999999, .{});
-    try testStringify("4.2e+01", @as(f32, 42), .{});
-    try testStringify("4.2e+01", @as(f64, 42), .{});
+    try testStringify("4.2e1", @as(f32, 42), .{});
+    try testStringify("4.2e1", @as(f64, 42), .{});
     try testStringify("\"ItBroke\"", @as(anyerror, error.ItBroke), .{});
     try testStringify("\"ItBroke\"", error.ItBroke, .{});
 }