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

fix for stringify array replacer mozilla/rhino#725 #876

Merged
merged 1 commit into from
May 5, 2021

Conversation

tonygermano
Copy link
Contributor

  • Per spec, Numbers in an array replacer should be converted to strings
    prior to adding to the property list
  • Duplicates should be removed during construction of the property list
  • Changed some variables declared as List to Collection instead because
    that is sufficient for how they are being used
  • Moved LinkedList to array conversion from happening in every iteration of
    the jo method to happening once in the stringify method
  • Convert strings items representing integers to their Integer value for
    correct property lookup

fixes #725

@gbrail gbrail self-assigned this May 3, 2021
Copy link
Collaborator

@gbrail gbrail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me, but I'd like to see that some tests are included. Does it make sense to wait and merge this after we get more tests from test262 working, or are there some other tests that you can add?

@tonygermano
Copy link
Contributor Author

I can add a test using the examples from the linked issue. I didn't know if I needed to since it's going to be covered by test262, hopefully in the near-ish future.

@rbri
Copy link
Collaborator

rbri commented May 3, 2021

I plan to go forward with test262 updates in small steps on a weekly basis

- Per spec, Numbers in an array replacer should be converted to strings
  prior to adding to the property list
- Duplicates should be removed during construction of the property list
- Changed some variables declared as List  to Collection instead because
  that is sufficient for how they are being used
- Moved List to array conversion from happening in every iteration of
  the jo method to being called once in the stringify method
- Convert strings items representing integers to their Integer value for
  correct property lookup
@tonygermano tonygermano force-pushed the json-stringify-replacer-bug branch from 052fbe1 to 2a3fd06 Compare May 4, 2021 07:37
@tonygermano
Copy link
Contributor Author

@gbrail I added some tests. The first time CircleCI tried to build, it failed with:

java.lang.AssertionError: In "testsrc/tests/js1_5/Regress/regress-211590.js":
 FAILED! Math.random should be random : Expected value 'between 48% and 52%', Actual value ' is 52.060' 

I reran the CircleCI build without changing any code, and it passed the second time. I'm guessing it was just a fluke with the rng.

@gbrail
Copy link
Collaborator

gbrail commented May 5, 2021

Works for me. Thanks!

@gbrail gbrail merged commit 8e8c27c into mozilla:master May 5, 2021
@tonygermano tonygermano deleted the json-stringify-replacer-bug branch May 11, 2021 23:55
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

Successfully merging this pull request may close these issues.

An issue about JSON.stringify
3 participants