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

Test with nondeterministic ordering when iterating object data #6

Merged
merged 8 commits into from
Mar 5, 2024

Conversation

jg-rp
Copy link
Owner

@jg-rp jg-rp commented Mar 4, 2024

This PR adds nondeterministic to JSONPathEnvironmentOptions and environment variables to control nondeterminism and the location of cts.json when testing for compliance. If the nondeterministic option is true, an object's entries will be shuffled prior to application of the wildcard selector, descendent segment and filter selector.

To point compliance.test.ts at a version of cts.json other than the one included as a submodule, use the JSONP3_CTS_PATH environment variable. And use JSONP3_CTS_NONDETERMINISTIC to enable nondeterminism for compliance.test.ts.

For example, in bash:

JSONP3_CTS_PATH=/tmp/jsonpath-compliance-test-suite/cts.json JSONP3_CTS_NONDETERMINISTIC=true npm test -- compliance

@jg-rp
Copy link
Owner Author

jg-rp commented Mar 5, 2024

Benchmarks show no discernible difference between calling Object.entries() and the extra redirection from calling JSONPathEnvironment.entries() when iterating objects. So there's no reason not to merge this.

@jg-rp jg-rp merged commit b5d8601 into main Mar 5, 2024
12 checks passed
@jg-rp jg-rp deleted the nondeterministic branch March 5, 2024 14:21
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.

1 participant