test262: JSON conformance fixes (wave 15) - #78
Merged
Conversation
Two SerializeJSONProperty conformance fixes (sec-serializejsonproperty): - Step 4.a-4.c: a Number/String/Boolean wrapper object (new Number(n), new String(s), new Boolean(b)) now serializes as its wrapped primitive instead of an empty object, so JSON.stringify(new Boolean(true)) is "true", including wrappers nested in an object/array or returned from a toJSON/replacer. Adds json_unwrap_primitive; matches test262 JSON/stringify/value-boolean-object. - SerializeJSONObject/SerializeJSONArray step 1: a cyclical structure now throws a TypeError (catchable by JS try/catch) instead of looping forever. json_serialize_cell keeps an ancestor stack in the process dictionary, pushed on entry and popped on exit, so a value that merely appears twice in sibling positions (a diamond) is still serialized. Clears the six JSON/stringify circular-reference hangs. Adds spec-driven tests mirroring the test262 cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raises JSON/stringify test262 conformance.
Fixes (sec-serializejsonproperty)
Wrapper-object unwrapping (step 4.a-4.c).
new Number(n)/new String(s)/new Boolean(b)now serialize as their wrapped primitive rather than an empty object, including wrappers nested in an object/array or produced by atoJSON/replacer. FixesJSON/stringify/value-boolean-object.Cyclical-structure detection (SerializeJSONObject/Array step 1). A self-referential object/array now throws a catchable TypeError instead of hanging.
json_serialize_cellkeeps an ancestor stack (pushed on entry, popped on exit) so a diamond (same ref in sibling positions) is still serialized. Clears all sixJSON/stringify/*circular*hangs.Impact
JSON/stringify + JSON/parse run tally: pass 65 -> 72, timeouts 6 -> 0. No new failures.
Runtime changes are confined to the JSON serializer (
json_serialize_value,json_serialize_cell,json_stringify); no shared helpers touched, no new FFI exports. Spec-driven tests appended at EOF ofjs_compiler_test.gleam.