javy-fuzz: Compare values instead of strings. #706
Merged
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.
This commit introduces value comparison for the json-differential target.
The motivation behind this change is to overcome the complexity of float value formatting.
JavaScript has very complex rules for Number formatting, for example, numbers that have magnitude of 10^21, independent of the sign, will be formatted via scientific notation. I was able to achieve certain format parity by writing a custom serde serializer formatter and relying on crates like
ryu
andlexical
. Even though this worked to an extent, there are some unwritten rules to my knowledge that make it harder to achieve full formatting parity. For example, in some cases the scientific notation would include the exponent with a sign e.g.,e+
ore-
depending on how big the number is. In the case oflexical
orryu
even though the numerical value is the same, no signs are used, which makes it harder to perform differential testing.Having to post-process the resulting string, will most likely incur in a performance penalty that I'm not sure is worth, especially given that no issues have been reported regarding the numerical value during my testing.
Due to all these reasons, this commit switches toward value comparison rahter than format/string comparison by parsing the stringified JSON into
serde_json::Value
and asserting equality on top of it.Checklist
javy-cli
andjavy-core
do not require updating CHANGELOG files.