eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.27k stars 721 forks source link

Errors in double unit tests #460

Open andrewcraik opened 6 years ago

andrewcraik commented 6 years ago

The tests in openj9/test/Java8andUp/src/org/openj9/test/floatsanity/custom/Check1ULPMath.java have a pattern which says:

if (Double.isNaN(expected)) { Assert.assertTrue(Double.isNaN(expected), operation); } else { Assert.assertEquals(result, expected, 0, operation); }

The isNan test is not needed - it is handled by assertEquals and isNaN results will never fail because we only ever test the expected value. It may be better for these tests keep the expected value as a long and to only do Double.longBitsToDouble to generate the operand(s), do the test, and then use Double.doubleToLongBits which will then make the comparisons bit accurate without floating point math which happens in the Asserts for double and float even if the delta is 0.

andrewcraik commented 6 years ago

@smlambert FYI

mgaudet commented 6 years ago

You can make your text show up preformatted by either fencing it with three backticks, or spacing with four spaces:

```
fenced code shows up pre
```
    four spaces also 
    leads to pre

For inline pre, wrap the section with a single backtick:

Lorem ipsum `<html>` dolor sit amet

See more in the GitHub Guide to Mastering Markdown