URGENT: JDK 9 RFR of JDK-8142501: nashorn tests failing after recent changes
Joseph D. Darcy
joe.darcy at oracle.com
Thu Nov 12 02:20:03 UTC 2015
Greetings,
Recent Nashorn changes, JDK-8010803, introduced multiple cross-platform
test failures into JDK 9:
src/jdk/nashorn/internal/runtime/doubleconv/test/BignumDtoaTest.java
src/jdk/nashorn/internal/runtime/doubleconv/test/FastDtoaTest.java
src/jdk/nashorn/internal/runtime/doubleconv/test/FixedDtoaTest.java
src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java
Not sure how these tests were run such that they passed before being pushed.
In any case, in the interests of having passing tests again, please
quickly review the patch below to correct a class name typo and use a
proper idiom for reading text files from the test source directory.
For the latter point, instead of trying to use
new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("resources/foo.txt")))
to read a text file use
try {
new BufferedReader(new
InputStreamReader(new
FileInputStream(new
File(System.getProperty("test.src", "."),
"resources/foo.txt"))))
...
} catch (FileNotFoundException fnfe) {
throw new RuntimeException(fnfe);
}
-Joe
---
a/test/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumDtoaTest.java
Wed Nov 11 16:35:38 2015 +0100
+++
b/test/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumDtoaTest.java
Wed Nov 11 18:15:01 2015 -0800
@@ -289,67 +289,87 @@
@Test
public void testBignumShortest() {
- new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("resources/gay-shortest.txt")))
+ try {
+ new BufferedReader(new
+ InputStreamReader(new
+ FileInputStream(new File(System.getProperty("test.src", "."),
+ "resources/gay-shortest.txt"))))
.lines()
.forEach(line -> {
- if (line.isEmpty() || line.startsWith("//")) {
- return; // comment or empty line
- }
- final String[] tokens = line.split(",\\s+");
- assertEquals(tokens.length, 3, "*" + line + "*");
- final double v = Double.parseDouble(tokens[0]);
- final String str = tokens[1].replace('"', ' ').trim();;
- final int point = Integer.parseInt(tokens[2]);
- final DtoaBuffer buffer = new DtoaBuffer(BUFFER_SIZE);
+ if (line.isEmpty() || line.startsWith("//")) {
+ return; // comment or empty line
+ }
+ final String[] tokens = line.split(",\\s+");
+ assertEquals(tokens.length, 3, "*" + line
+ "*");
+ final double v =
Double.parseDouble(tokens[0]);
+ final String str = tokens[1].replace('"',
' ').trim();;
+ final int point = Integer.parseInt(tokens[2]);
+ final DtoaBuffer buffer = new
DtoaBuffer(BUFFER_SIZE);
- DoubleConversion.bignumDtoa(v, DtoaMode.SHORTEST,
0, buffer);
- assertEquals(str, buffer.getRawDigits());
- assertEquals(point, buffer.getDecimalPoint());
- });
+ DoubleConversion.bignumDtoa(v,
DtoaMode.SHORTEST, 0, buffer);
+ assertEquals(str, buffer.getRawDigits());
+ assertEquals(point, buffer.getDecimalPoint());
+ });
+ } catch (FileNotFoundException fnfe) {
+ throw new RuntimeException(fnfe);
+ }
}
@Test
public void testBignumFixed() {
- new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("resources/gay-fixed.txt")))
+ try {
+ new BufferedReader(new
+ InputStreamReader(new
+ FileInputStream(new File(System.getProperty("test.src", "."),
+ "resources/gay-fixed.txt"))))
.lines()
.forEach(line -> {
- if (line.isEmpty() || line.startsWith("//")) {
- return; // comment or empty line
- }
- final String[] tokens = line.split(",\\s+");
- assertEquals(tokens.length, 4);
- final double v = Double.parseDouble(tokens[0]);
- final int digits = Integer.parseInt(tokens[1]);
- final String str = tokens[2].replace('"', ' ').trim();
- final int point = Integer.parseInt(tokens[3]);
- final DtoaBuffer buffer = new DtoaBuffer(BUFFER_SIZE);
+ if (line.isEmpty() || line.startsWith("//")) {
+ return; // comment or empty line
+ }
+ final String[] tokens = line.split(",\\s+");
+ assertEquals(tokens.length, 4);
+ final double v =
Double.parseDouble(tokens[0]);
+ final int digits =
Integer.parseInt(tokens[1]);
+ final String str = tokens[2].replace('"',
' ').trim();
+ final int point = Integer.parseInt(tokens[3]);
+ final DtoaBuffer buffer = new
DtoaBuffer(BUFFER_SIZE);
- DoubleConversion.bignumDtoa(v, DtoaMode.FIXED,
digits, buffer);
- assertEquals(str,
trimRepresentation(buffer.getRawDigits()));
- assertEquals(point, buffer.getDecimalPoint());
- });
+ DoubleConversion.bignumDtoa(v,
DtoaMode.FIXED, digits, buffer);
+ assertEquals(str,
trimRepresentation(buffer.getRawDigits()));
+ assertEquals(point, buffer.getDecimalPoint());
+ });
+ } catch (FileNotFoundException fnfe) {
+ throw new RuntimeException(fnfe);
+ }
}
@Test
public void testBignumPrecision() {
- new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("resources/gay-precision.txt")))
+ try {
+ new BufferedReader(new
+ InputStreamReader(new
+ FileInputStream(new File(System.getProperty("test.src", "."),
+ "resources/gay-precision.txt"))))
.lines()
.forEach(line -> {
- if (line.isEmpty() || line.startsWith("//")) {
- return; // comment or empty line
- }
- final String[] tokens = line.split(",\\s+");
- assertEquals(tokens.length, 4);
- final double v = Double.parseDouble(tokens[0]);
- final int digits = Integer.parseInt(tokens[1]);
- final String str = tokens[2].replace('"', ' ').trim();
- final int point = Integer.parseInt(tokens[3]);
- final DtoaBuffer buffer = new DtoaBuffer(BUFFER_SIZE);
+ if (line.isEmpty() || line.startsWith("//")) {
+ return; // comment or empty line
+ }
+ final String[] tokens = line.split(",\\s+");
+ assertEquals(tokens.length, 4);
+ final double v =
Double.parseDouble(tokens[0]);
+ final int digits =
Integer.parseInt(tokens[1]);
+ final String str = tokens[2].replace('"',
' ').trim();
+ final int point = Integer.parseInt(tokens[3]);
+ final DtoaBuffer buffer = new
DtoaBuffer(BUFFER_SIZE);
- DoubleConversion.bignumDtoa(v, DtoaMode.PRECISION,
digits, buffer);
- assertEquals(str,
trimRepresentation(buffer.getRawDigits()));
- assertEquals(point, buffer.getDecimalPoint());
- });
+ DoubleConversion.bignumDtoa(v,
DtoaMode.PRECISION, digits, buffer);
+ assertEquals(str,
trimRepresentation(buffer.getRawDigits()));
+ assertEquals(point, buffer.getDecimalPoint());
+ });
+ } catch (FileNotFoundException fnfe) {
+ throw new RuntimeException(fnfe);
+ }
}
-
}
diff -r e1dd1c03e9a9
test/src/jdk/nashorn/internal/runtime/doubleconv/test/FastDtoaTest.java
---
a/test/src/jdk/nashorn/internal/runtime/doubleconv/test/FastDtoaTest.java Wed
Nov 11 16:35:38 2015 +0100
+++
b/test/src/jdk/nashorn/internal/runtime/doubleconv/test/FastDtoaTest.java Wed
Nov 11 18:15:01 2015 -0800
@@ -33,6 +33,10 @@
package jdk.nashorn.internal.runtime.doubleconv.test;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -243,29 +247,36 @@
final AtomicInteger succeeded = new AtomicInteger();
final AtomicBoolean neededMaxLength = new AtomicBoolean();
- new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("resources/gay-shortest.txt")))
+ try {
+ new BufferedReader(new
+ InputStreamReader(new
+ FileInputStream(new File(System.getProperty("test.src", "."),
+ "resources/gay-shortest.txt"))))
.lines()
.forEach(line -> {
- if (line.isEmpty() || line.startsWith("//")) {
- return; // comment or empty line
- }
- final String[] tokens = line.split(",\\s+");
- assertEquals(tokens.length, 3, "*" + line + "*");
- final double v = Double.parseDouble(tokens[0]);
- final String str = tokens[1].replace('"', ' ').trim();;
- final int point = Integer.parseInt(tokens[2]);
- final DtoaBuffer buffer = new DtoaBuffer(kBufferSize);
- total.getAndIncrement();
+ if (line.isEmpty() || line.startsWith("//")) {
+ return; // comment or empty line
+ }
+ final String[] tokens = line.split(",\\s+");
+ assertEquals(tokens.length, 3, "*" + line
+ "*");
+ final double v =
Double.parseDouble(tokens[0]);
+ final String str = tokens[1].replace('"',
' ').trim();;
+ final int point = Integer.parseInt(tokens[2]);
+ final DtoaBuffer buffer = new
DtoaBuffer(kBufferSize);
+ total.getAndIncrement();
- if (DoubleConversion.fastDtoaShortest(v, buffer)) {
- assertEquals(str, buffer.getRawDigits());
- assertEquals(point, buffer.getDecimalPoint());
- succeeded.getAndIncrement();
- if (buffer.getLength() ==
DtoaBuffer.kFastDtoaMaximalLength) {
- neededMaxLength.set(true);
- }
- }
- });
+ if (DoubleConversion.fastDtoaShortest(v,
buffer)) {
+ assertEquals(str, buffer.getRawDigits());
+ assertEquals(point,
buffer.getDecimalPoint());
+ succeeded.getAndIncrement();
+ if (buffer.getLength() ==
DtoaBuffer.kFastDtoaMaximalLength) {
+ neededMaxLength.set(true);
+ }
+ }
+ });
+ } catch (FileNotFoundException fnfe) {
+ throw new RuntimeException(fnfe);
+ }
assertTrue(succeeded.get() * 1.0 / total.get() > 0.99);
assertTrue(neededMaxLength.get());
@@ -282,33 +293,41 @@
final AtomicInteger succeeded_15 = new AtomicInteger();
final AtomicInteger total_15 = new AtomicInteger();
- new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("resources/gay-precision.txt")))
+ try {
+ new BufferedReader(new
+ InputStreamReader(new
+ FileInputStream(new File(System.getProperty("test.src", "."),
+ "resources/gay-precision.txt"))))
+
.lines()
.forEach(line -> {
- if (line.isEmpty() || line.startsWith("//")) {
- return; // comment or empty line
- }
- final String[] tokens = line.split(",\\s+");
- assertEquals(tokens.length, 4);
- final double v = Double.parseDouble(tokens[0]);
- final int digits = Integer.parseInt(tokens[1]);
- final String str = tokens[2].replace('"', ' ').trim();
- final int point = Integer.parseInt(tokens[3]);
- final DtoaBuffer buffer = new DtoaBuffer(kBufferSize);
- total.getAndIncrement();
- if (digits <= 15) {
- total_15.getAndIncrement();
- }
+ if (line.isEmpty() || line.startsWith("//")) {
+ return; // comment or empty line
+ }
+ final String[] tokens = line.split(",\\s+");
+ assertEquals(tokens.length, 4);
+ final double v =
Double.parseDouble(tokens[0]);
+ final int digits =
Integer.parseInt(tokens[1]);
+ final String str = tokens[2].replace('"',
' ').trim();
+ final int point = Integer.parseInt(tokens[3]);
+ final DtoaBuffer buffer = new
DtoaBuffer(kBufferSize);
+ total.getAndIncrement();
+ if (digits <= 15) {
+ total_15.getAndIncrement();
+ }
- if (DoubleConversion.fastDtoaCounted(v, digits,
buffer)) {
- assertEquals(str,
trimRepresentation(buffer.getRawDigits()));
- assertEquals(point, buffer.getDecimalPoint());
- succeeded.getAndIncrement();
- if (digits <= 15) {
- succeeded_15.getAndIncrement();
- }
- }
- });
+ if (DoubleConversion.fastDtoaCounted(v,
digits, buffer)) {
+ assertEquals(str,
trimRepresentation(buffer.getRawDigits()));
+ assertEquals(point,
buffer.getDecimalPoint());
+ succeeded.getAndIncrement();
+ if (digits <= 15) {
+ succeeded_15.getAndIncrement();
+ }
+ }
+ });
+ } catch (FileNotFoundException fnfe) {
+ throw new RuntimeException(fnfe);
+ }
// The precomputed numbers contain many entries with many
requested
// digits. These have a high failure rate and we therefore
expect a lower
diff -r e1dd1c03e9a9
test/src/jdk/nashorn/internal/runtime/doubleconv/test/FixedDtoaTest.java
---
a/test/src/jdk/nashorn/internal/runtime/doubleconv/test/FixedDtoaTest.java
Wed Nov 11 16:35:38 2015 +0100
+++
b/test/src/jdk/nashorn/internal/runtime/doubleconv/test/FixedDtoaTest.java
Wed Nov 11 18:15:01 2015 -0800
@@ -58,6 +58,10 @@
package jdk.nashorn.internal.runtime.doubleconv.test;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.concurrent.atomic.AtomicInteger;
import jdk.nashorn.internal.runtime.doubleconv.DoubleConversion;
@@ -636,30 +640,37 @@
final AtomicInteger total = new AtomicInteger();
final AtomicInteger succeeded = new AtomicInteger();
- new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("resources/gay-fixed.txt")))
+ try {
+ new BufferedReader(new
+ InputStreamReader(new
+ FileInputStream(new File(System.getProperty("test.src", "."),
+ "resources/gay-fixed.txt"))))
.lines()
.forEach(line -> {
- if (line.isEmpty() || line.startsWith("//")) {
- return; // comment or empty line
- }
- final String[] tokens = line.split(",\\s+");
- assertEquals(tokens.length, 4);
- final double v = Double.parseDouble(tokens[0]);
- final int digits = Integer.parseInt(tokens[1]);
- final String str = tokens[2].replace('"', ' ').trim();;
- final int point = Integer.parseInt(tokens[3]);
- final DtoaBuffer buffer = new DtoaBuffer(kBufferSize);
- total.getAndIncrement();
+ if (line.isEmpty() || line.startsWith("//")) {
+ return; // comment or empty line
+ }
+ final String[] tokens = line.split(",\\s+");
+ assertEquals(tokens.length, 4);
+ final double v =
Double.parseDouble(tokens[0]);
+ final int digits =
Integer.parseInt(tokens[1]);
+ final String str = tokens[2].replace('"',
' ').trim();;
+ final int point = Integer.parseInt(tokens[3]);
+ final DtoaBuffer buffer = new
DtoaBuffer(kBufferSize);
+ total.getAndIncrement();
- if (DoubleConversion.fixedDtoa(v, digits, buffer)) {
- assertEquals(str, buffer.getRawDigits());
- assertEquals(point, buffer.getDecimalPoint());
- succeeded.getAndIncrement();
- }
- });
+ if (DoubleConversion.fixedDtoa(v, digits,
buffer)) {
+ assertEquals(str, buffer.getRawDigits());
+ assertEquals(point,
buffer.getDecimalPoint());
+ succeeded.getAndIncrement();
+ }
+ });
- // should work for all numbers
- assertEquals(succeeded.get(), total.get());
+ // should work for all numbers
+ assertEquals(succeeded.get(), total.get());
+ } catch (FileNotFoundException fnfe) {
+ throw new RuntimeException(fnfe);
+ }
}
}
diff -r e1dd1c03e9a9
test/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java
---
a/test/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java
Wed Nov 11 16:35:38 2015 +0100
+++
b/test/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java
Wed Nov 11 18:15:01 2015 -0800
@@ -44,7 +44,7 @@
* Ieee class tests
*
* @test
- * @run testng jdk.nashorn.internal.runtime.doubleconv.test.IeeeTest
+ * @run testng jdk.nashorn.internal.runtime.doubleconv.test.IeeeDoubleTest
*/
@SuppressWarnings({"unchecked", "javadoc"})
public class IeeeDoubleTest {
More information about the nashorn-dev
mailing list