Repository navigation
Add JSON number precision fixture - #77
Draft
leoromanovsky wants to merge 1 commit into
Draft
leoromanovsky wants to merge 1 commit into
leoromanovsky wants to merge 1 commit into
Conversation
A JSON variant value must keep each integer an integer and keep integers above 2^53 exact. The new json-number-precision-flag returns one variant with integers inside the double-precision range and floats, and one with integers above 2^53. The second case skips nodejs and web, because JavaScript numbers cannot hold those integers.
4 tasks done
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.
Motivation
A JSON variant value must return its numbers with their meaning unchanged. The README already requires adapters to "preserve the meaning and precision of the inputs and expected results". The existing case
test-json-config-flag.jsonchecks"integer": 1and"float": 1.0, but no case checks integers that a double cannot hold.An SDK that reads all JSON numbers as doubles returns
5.0for5, and changes integers above 2^53. For example,9007199254740993becomes9007199254740992. JSON values often carry IDs and counts, so this is a correctness bug.Changes
ufc-config.json: new flagjson-number-precision-flag(JSON).within-double:0,5,-7, the int32 limits,2147483648,9007199254740991(2^53 − 1), the floats5.0and0.25, and a nested object and list.above-double:9007199254740993, the int64 limits, and nested integers above 2^53.precision=above-doubleselectsabove-double. A static allocation serveswithin-double.evaluation-cases/test-json-number-precision.json: two cases.within-double, reasonSTATIC. It runs on all platforms.precision=above-double, resultabove-double, reasonTARGETING_MATCH. It skipsnodejsandweb, because JavaScript numbers cannot hold integers above 2^53.README.md: a list entry for the new case file, and one sentence in the runner section: for JSON values, an integer stays an integer, and integers above 2^53 stay exact where the platform can represent them.Decisions
within-doublecase still runs onnodejsandweb.Verification
python3 ci/validate-fixtures.py: validated 3 suites, 455 cases in 61 files.python3 -m unittest ci/test_validate_fixtures.py: 30 tests pass.CanonicalFixtureTest, with a change that keeps JSON integers exact (Return read-only JSON flag values with exact integers dd-trace-java#13484): all cases pass, including both new cases.Checklist
ufc-config.jsonevaluation-cases/