Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing plan for JSON-parse-with-source #4096

Open
29 of 49 tasks
ioannad opened this issue May 27, 2024 · 2 comments
Open
29 of 49 tasks

Testing plan for JSON-parse-with-source #4096

ioannad opened this issue May 27, 2024 · 2 comments

Comments

@ioannad
Copy link
Contributor

ioannad commented May 27, 2024

Proposal README
Proposal rendered spec

For testing the tests, the proposal is shipped in v8.


  • Tests for new function JSON.isRawJSON:
    • Boilerplate:
      • Function length.
      • Function name.
      • Property descriptor.
      • Function is not a constructor.
    • Can be invoked as a function with success cases:
      • An instance created by a call to JSON.rawJSON.
      • Some objects without an [[IsRawJSON]] internal slot: {}, [].
      • Some non-Objects: null, undefinded, a Boolean, a symbol, a number.
  • Tests for new function JSON.rawJSON:
    • Boilerplate:
      • Function length.
      • Function name.
      • Function is not a constructor.
      • Property descriptor.
    • Can be invoked as a function
      • Success cases
        • Number, negative number, string, true, false, null
        • Returned object has the correct shape (null prototype, rawJSON own property)
        • Returned object is frozen
      • Failure cases, throwing:
        • SyntaxError in case of:
          • The empty string.
          • A string starting or ending with a tab, a linefeed, a carriage return, or a space.
          • A non-Array object literal: {}.
          • An Array literal: [1].
        • TypeError when trying to extend a rawJSON result object.
  • Tests for the new abstract operations in the algorithm of JSON.parse, each test should have a callable reviver argument:
    • For paths in CreateJSONParseRecord, only success cases (normal output), a test for each branch:
      • an Array literal
      • an Object literal
      • an Object literal with a repeated key
      • NullLiteral, BooleanLiteral, NumericLiteral, StringLiteral, ArrayLiteral, ObjectLiteral, UnaryExpression
      • a combination of all the above success cases nested
    • For paths in InternalizeJSONProperty, and the interaction with JSON.stringify, test with a reviver that modifies the holder object, as mentioned in tc39 issue 39:
      • [array and plain object] overwrite of not-yet-processed entry should result in absence of source for that entry
        • primitive to non-primitive
        • non-primitive to primitive
        • non-primitive to a clone (same date but different identity)
        • primitive to a different primitive
      • [array and plain object] overwrite and restoration of not-yet-processed entry should preserve source for that entry
        • primitive
        • non-primitive
      • [array] splicing out an item should result in absence of source from the affected index forward
        • ...but restoring items at their original index should preserve source
  • Test the overall intended functionality with examples from the proposal README and slides (linked in README).
    • Test that reviver function is applied to the source, not the parsed value, by roundtripping:
      • JSON.parse(" 9999999999999999", (key, val) => BigInt(val)) // → 9999999999999999n
      • other?
@ioannad
Copy link
Contributor Author

ioannad commented May 27, 2024

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.

@ptomato
Copy link
Contributor

ptomato commented Jul 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants