Repository navigation
Conversation
JavaFloatHolder.compare and JavaDoubleHolder.compare order NaN above every other value, so a NaN instance value passed minInclusive and minExclusive, and a NaN max bound accepted every number. XML Schema makes NaN equal to itself but incomparable with every other value, so it satisfies no bound facet of a non-NaN bound. The four bound checks in both holders now also fail when exactly one side is NaN.
pjfanning
left a comment
There was a problem hiding this comment.
Thanks, the change looks right to me: incomparable only fires when exactly one side is NaN, so it does not overlap with #174.
One request before approving: the tests only use a bound of 0. The description also says that NaN against a NaN bound behaves as before and that a NaN max bound no longer accepts every number, but neither is pinned by a test. Could you add cases with a NaN bound to IncomparableMinFacetValidateTest (NaN value vs NaN bound for each of the four facets, and a non-NaN value vs a NaN bound)?
Possible follow-up, not needed here: compareValue still returns 1/-1 for NaN against a number rather than 2 (incomparable).
|
Added, b4cac35. Two new elements per facet with a
That's Noted on |
Differential run,
XmlObject.validate()vs the JDK Xerces validator,xs:doublewith<xs:minInclusive value="0"/>:How it was found: I ran NaN, INF, -INF and 0 against each of the four bound facets on
xs:floatandxs:double, with bounds of 0, NaN, INF and -INF. 24 of the 128 cases disagreed with Xerces. Every one had NaN on exactly one side.Observations:
JavaFloatHolder.compareandJavaDoubleHolder.comparefall back to the bit patterns, which puts NaN above every other value.minInclusiveandminExclusiveaccept it. A NaN max bound accepts every number.Conclusion: a schema that bounds a float or double with
minInclusive="0"does not keep NaN out, and NaN then slips past range checks in the code that reads the value, since every comparison with it is false. The four bound checks inJavaFloatHolderEx.validateValueandJavaDoubleHolderEx.validateValuenow also fail when exactly one side is NaN. NaN against a NaN bound, and every non-NaN value, behave as before. After the fix all 128 cases agree with Xerces.Cases added to
IncomparableMinFacetValidateTest.nanFailsEveryBoundfails on trunk and passes with the fix../gradlew testis otherwise green, apart fromCompilationTests.partialsandSaverTest.testLengthAssertion, which fail the same way on an untouched trunk checkout here on Windows (they look like line-ending issues).