test262
test262 copied to clipboard
Testing plan for JSON-parse-with-source
Proposal README Proposal rendered spec
For testing the tests, the proposal is shipped in v8.
- [x] Tests for new function
JSON.isRawJSON:- [x] Boilerplate:
- [x] Function length.
- [x] Function name.
- [x] Property descriptor.
- [x] Function is not a constructor.
- [x] Can be invoked as a function with success cases:
- [x] An instance created by a call to
JSON.rawJSON. - [x] Some objects without an
[[IsRawJSON]]internal slot:{},[]. - [x] Some non-Objects:
null,undefinded, a Boolean, a symbol, a number.
- [x] An instance created by a call to
- [x] Boilerplate:
- [x] Tests for new function
JSON.rawJSON:- [x] Boilerplate:
- [x] Function length.
- [x] Function name.
- [x] Function is not a constructor.
- [x] Property descriptor.
- [x] Can be invoked as a function
- [x] Success cases
- [x] Number, negative number, string,
true,false,null - [x] Returned object has the correct shape (null prototype,
rawJSONown property) - [x] Returned object is frozen #4682
- [x] Number, negative number, string,
- [x] Failure cases, throwing:
- [x]
SyntaxErrorin case of:- [x] The empty string.
- [x] A string starting or ending with a tab, a linefeed, a carriage return, or a space.
- [x] A non-Array object literal:
{}. - [x] An Array literal:
[1].
- [x]
TypeErrorwhen trying to extend a rawJSON result object. #4682
- [x]
- [x] Success cases
- [x] Boilerplate:
- [x] Tests for the new abstract operations in the algorithm of
JSON.parse, each test should have a callablereviverargument:- [x] For paths in
CreateJSONParseRecord, only success cases (normal output), a test for each branch:- [x] an Array literal
- [x] an Object literal
- [x] an Object literal with a repeated key
- [x] NullLiteral, BooleanLiteral, NumericLiteral, StringLiteral, ArrayLiteral, ObjectLiteral, UnaryExpression
- [x] a combination of all the above success cases nested
- [x] For paths in
InternalizeJSONProperty, and the interaction withJSON.stringify, test with areviverthat modifies the holder object, as mentioned in tc39 issue 39: #4682- [x] [array and plain object] overwrite of not-yet-processed entry should result in absence of source for that entry
- [x] primitive to non-primitive
- [x] non-primitive to primitive
- [x] non-primitive to a clone (same data but different identity)
- [x] primitive to a different primitive
- [x] [array and plain object] overwrite and restoration of not-yet-processed entry should preserve source for that entry
- [x] primitive
- [x] non-primitive
- [x] [array] splicing out an item should result in absence of source from the affected index forward
- [x] ...but restoring items at their original index should preserve source
- [x] [array and plain object] overwrite of not-yet-processed entry should result in absence of source for that entry
- [x] For paths in
- [x] Test the overall intended functionality with examples from the proposal README and slides (linked in README).
- [x] Test that reviver function is applied to the source, not the parsed value, by roundtripping:
- [x]
JSON.parse(" 9999999999999999", (key, val) => BigInt(val)) // → 9999999999999999n - other?
- [x]
- [x] Test that reviver function is applied to the source, not the parsed value, by roundtripping:
I hope I didn't miss important test cases, and that the plan is not too much or too little. Any comments are very welcome!
I make the start by migrating the staging tests by the v8 project authors.
I removed "Brand check for this method" - JSON.isRawJSON and JSON.rawJSON are static methods, so there's no instance to brand-check.
Here is one more suggestion: On the return value of JSON.rawJSON(), the rawJSON property cannot be modified or deleted and has the correct property descriptor.