提交 6c68010f 编写于 作者: A amlu

8076458: java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java timeout

Reviewed-by: psandoz
Contributed-by: huaming.li@oracle.com
上级 66348935
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -41,6 +41,7 @@ public class DoubleStreamTestDataProvider { ...@@ -41,6 +41,7 @@ public class DoubleStreamTestDataProvider {
private static final double[] pseudoRandom; private static final double[] pseudoRandom;
private static final Object[][] testData; private static final Object[][] testData;
private static final Object[][] testSmallData;
private static final Object[][] spliteratorTestData; private static final Object[][] spliteratorTestData;
static { static {
...@@ -78,11 +79,15 @@ public class DoubleStreamTestDataProvider { ...@@ -78,11 +79,15 @@ public class DoubleStreamTestDataProvider {
static { static {
{ {
List<Object[]> list = new ArrayList<>(); List<Object[]> listSmall = new ArrayList<>();
List<Object[]> list1000 = new ArrayList<>();
List<Object[]> list = null;
for (Object[] data : arrays) { for (Object[] data : arrays) {
final Object name = data[0]; final Object name = data[0];
final double[] doubles = (double[]) data[1]; final double[] doubles = (double[]) data[1];
list = doubles.length >= 1000 ? list1000 : listSmall;
list.add(new Object[]{"array:" + name, list.add(new Object[]{"array:" + name,
TestData.Factory.ofArray("array:" + name, doubles)}); TestData.Factory.ofArray("array:" + name, doubles)});
...@@ -93,7 +98,9 @@ public class DoubleStreamTestDataProvider { ...@@ -93,7 +98,9 @@ public class DoubleStreamTestDataProvider {
list.add(new Object[]{"SpinedList:" + name, list.add(new Object[]{"SpinedList:" + name,
TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)}); TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
} }
testData = list.toArray(new Object[0][]); testSmallData = listSmall.toArray(new Object[0][]);
list1000.addAll(listSmall);
testData = list1000.toArray(new Object[0][]);
} }
{ {
...@@ -136,6 +143,11 @@ public class DoubleStreamTestDataProvider { ...@@ -136,6 +143,11 @@ public class DoubleStreamTestDataProvider {
return testData; return testData;
} }
@DataProvider(name = "DoubleStreamTestData.small")
public static Object[][] makeSmallDoubleStreamTestData() {
return testSmallData;
}
// returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>) // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
@DataProvider(name = "DoubleSpliterator") @DataProvider(name = "DoubleSpliterator")
public static Object[][] spliteratorProvider() { public static Object[][] spliteratorProvider() {
......
/* /*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -41,6 +41,7 @@ public class IntStreamTestDataProvider { ...@@ -41,6 +41,7 @@ public class IntStreamTestDataProvider {
private static final int[] pseudoRandom; private static final int[] pseudoRandom;
private static final Object[][] testData; private static final Object[][] testData;
private static final Object[][] testSmallData;
private static final Object[][] spliteratorTestData; private static final Object[][] spliteratorTestData;
static { static {
...@@ -78,11 +79,15 @@ public class IntStreamTestDataProvider { ...@@ -78,11 +79,15 @@ public class IntStreamTestDataProvider {
static { static {
{ {
List<Object[]> list = new ArrayList<>(); List<Object[]> listSmall = new ArrayList<>();
List<Object[]> list1000 = new ArrayList<>();
List<Object[]> list = null;
for (Object[] data : arrays) { for (Object[] data : arrays) {
final Object name = data[0]; final Object name = data[0];
final int[] ints = (int[]) data[1]; final int[] ints = (int[]) data[1];
list = ints.length >= 1000 ? list1000 : listSmall;
list.add(new Object[]{"array:" + list.add(new Object[]{"array:" +
name, TestData.Factory.ofArray("array:" + name, ints)}); name, TestData.Factory.ofArray("array:" + name, ints)});
...@@ -98,7 +103,9 @@ public class IntStreamTestDataProvider { ...@@ -98,7 +103,9 @@ public class IntStreamTestDataProvider {
list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length, list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length,
() -> IntStream.rangeClosed(0, ints.length))); () -> IntStream.rangeClosed(0, ints.length)));
} }
testData = list.toArray(new Object[0][]); testSmallData = listSmall.toArray(new Object[0][]);
list1000.addAll(listSmall);
testData = list1000.toArray(new Object[0][]);
} }
{ {
...@@ -150,6 +157,11 @@ public class IntStreamTestDataProvider { ...@@ -150,6 +157,11 @@ public class IntStreamTestDataProvider {
return testData; return testData;
} }
@DataProvider(name = "IntStreamTestData.small")
public static Object[][] makeSmallIntStreamTestData() {
return testSmallData;
}
// returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>) // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
@DataProvider(name = "IntSpliterator") @DataProvider(name = "IntSpliterator")
public static Object[][] spliteratorProvider() { public static Object[][] spliteratorProvider() {
......
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -41,6 +41,7 @@ public class LongStreamTestDataProvider { ...@@ -41,6 +41,7 @@ public class LongStreamTestDataProvider {
private static final long[] pseudoRandom; private static final long[] pseudoRandom;
private static final Object[][] testData; private static final Object[][] testData;
private static final Object[][] testSmallData;
private static final Object[][] spliteratorTestData; private static final Object[][] spliteratorTestData;
static { static {
...@@ -78,11 +79,15 @@ public class LongStreamTestDataProvider { ...@@ -78,11 +79,15 @@ public class LongStreamTestDataProvider {
static { static {
{ {
List<Object[]> list = new ArrayList<>(); List<Object[]> listSmall = new ArrayList<>();
List<Object[]> list1000 = new ArrayList<>();
List<Object[]> list = null;
for (Object[] data : arrays) { for (Object[] data : arrays) {
final Object name = data[0]; final Object name = data[0];
final long[] longs = (long[]) data[1]; final long[] longs = (long[]) data[1];
list = longs.length >= 1000 ? list1000 : listSmall;
list.add(new Object[]{"array:" + name, list.add(new Object[]{"array:" + name,
TestData.Factory.ofArray("array:" + name, longs)}); TestData.Factory.ofArray("array:" + name, longs)});
...@@ -98,7 +103,9 @@ public class LongStreamTestDataProvider { ...@@ -98,7 +103,9 @@ public class LongStreamTestDataProvider {
list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length, list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length,
() -> LongStream.rangeClosed(0, longs.length))); () -> LongStream.rangeClosed(0, longs.length)));
} }
testData = list.toArray(new Object[0][]); testSmallData = listSmall.toArray(new Object[0][]);
list1000.addAll(listSmall);
testData = list1000.toArray(new Object[0][]);
} }
{ {
...@@ -150,6 +157,11 @@ public class LongStreamTestDataProvider { ...@@ -150,6 +157,11 @@ public class LongStreamTestDataProvider {
return testData; return testData;
} }
@DataProvider(name = "LongStreamTestData.small")
public static Object[][] makeSmallLongStreamTestData() {
return testSmallData;
}
// returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>) // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
@DataProvider(name = "LongSpliterator") @DataProvider(name = "LongSpliterator")
public static Object[][] spliteratorProvider() { public static Object[][] spliteratorProvider() {
......
/* /*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -46,6 +46,7 @@ public class StreamTestDataProvider { ...@@ -46,6 +46,7 @@ public class StreamTestDataProvider {
private static final Integer[] pseudoRandom; private static final Integer[] pseudoRandom;
private static final Object[][] testData; private static final Object[][] testData;
private static final Object[][] testSmallData;
private static final Object[][] withNullTestData; private static final Object[][] withNullTestData;
private static final Object[][] spliteratorTestData; private static final Object[][] spliteratorTestData;
...@@ -84,12 +85,16 @@ public class StreamTestDataProvider { ...@@ -84,12 +85,16 @@ public class StreamTestDataProvider {
static { static {
{ {
List<Object[]> list = new ArrayList<>(); List<Object[]> listSmall = new ArrayList<>();
List<Object[]> list1000 = new ArrayList<>();
List<Object[]> list = null;
for (Object[] data : arrays) { for (Object[] data : arrays) {
final Object name = data[0]; final Object name = data[0];
final Integer[] ints = (Integer[])data[1]; final Integer[] ints = (Integer[])data[1];
final List<Integer> intsAsList = Arrays.asList(ints); final List<Integer> intsAsList = Arrays.asList(ints);
list = ints.length >= 1000 ? list1000 : listSmall;
list.add(arrayDataDescr("array:" + name, ints)); list.add(arrayDataDescr("array:" + name, ints));
list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList)); list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList));
list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList))); list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList)));
...@@ -114,7 +119,9 @@ public class StreamTestDataProvider { ...@@ -114,7 +119,9 @@ public class StreamTestDataProvider {
// @@@ Add more // @@@ Add more
} }
testData = list.toArray(new Object[0][]); testSmallData = listSmall.toArray(new Object[0][]);
list1000.addAll(listSmall);
testData = list1000.toArray(new Object[0][]);
} }
// Simple combination of numbers and null values, probably excessive but may catch // Simple combination of numbers and null values, probably excessive but may catch
...@@ -192,6 +199,11 @@ public class StreamTestDataProvider { ...@@ -192,6 +199,11 @@ public class StreamTestDataProvider {
return testData; return testData;
} }
@DataProvider(name = "StreamTestData<Integer>.small")
public static Object[][] makeSmallStreamTestData() {
return testSmallData;
}
@DataProvider(name = "withNull:StreamTestData<Integer>") @DataProvider(name = "withNull:StreamTestData<Integer>")
public static Object[][] makeStreamWithNullTestData() { public static Object[][] makeStreamWithNullTestData() {
return withNullTestData; return withNullTestData;
......
/* /*
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
/* /*
* @test * @test
* @summary flat-map operations * @summary flat-map operations
* @bug 8044047 * @bug 8044047 8076458
*/ */
package org.openjdk.tests.java.util.stream; package org.openjdk.tests.java.util.stream;
...@@ -76,7 +76,10 @@ public class FlatMapOpTest extends OpTestCase { ...@@ -76,7 +76,10 @@ public class FlatMapOpTest extends OpTestCase {
result = exerciseOps(data, s-> s.flatMap(e -> Stream.empty())); result = exerciseOps(data, s-> s.flatMap(e -> Stream.empty()));
assertEquals(0, result.size()); assertEquals(0, result.size());
}
@Test(dataProvider = "StreamTestData<Integer>.small", dataProviderClass = StreamTestDataProvider.class)
public void testOpsX(String name, TestData.OfRef<Integer> data) {
exerciseOps(data, s -> s.flatMap(mfLt)); exerciseOps(data, s -> s.flatMap(mfLt));
exerciseOps(data, s -> s.flatMap(integerRangeMapper)); exerciseOps(data, s -> s.flatMap(integerRangeMapper));
exerciseOps(data, s -> s.flatMap((Integer e) -> IntStream.range(0, e).boxed().limit(10))); exerciseOps(data, s -> s.flatMap((Integer e) -> IntStream.range(0, e).boxed().limit(10)));
...@@ -92,7 +95,10 @@ public class FlatMapOpTest extends OpTestCase { ...@@ -92,7 +95,10 @@ public class FlatMapOpTest extends OpTestCase {
result = exerciseOps(data, s -> s.flatMap(i -> IntStream.empty())); result = exerciseOps(data, s -> s.flatMap(i -> IntStream.empty()));
assertEquals(0, result.size()); assertEquals(0, result.size());
}
@Test(dataProvider = "IntStreamTestData.small", dataProviderClass = IntStreamTestDataProvider.class)
public void testIntOpsX(String name, TestData.OfInt data) {
exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, e))); exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, e)));
exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, e).limit(10))); exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, e).limit(10)));
} }
...@@ -107,7 +113,10 @@ public class FlatMapOpTest extends OpTestCase { ...@@ -107,7 +113,10 @@ public class FlatMapOpTest extends OpTestCase {
result = exerciseOps(data, s -> LongStream.empty()); result = exerciseOps(data, s -> LongStream.empty());
assertEquals(0, result.size()); assertEquals(0, result.size());
}
@Test(dataProvider = "LongStreamTestData.small", dataProviderClass = LongStreamTestDataProvider.class)
public void testLongOpsX(String name, TestData.OfLong data) {
exerciseOps(data, s -> s.flatMap(e -> LongStream.range(0, e))); exerciseOps(data, s -> s.flatMap(e -> LongStream.range(0, e)));
exerciseOps(data, s -> s.flatMap(e -> LongStream.range(0, e).limit(10))); exerciseOps(data, s -> s.flatMap(e -> LongStream.range(0, e).limit(10)));
} }
...@@ -122,7 +131,10 @@ public class FlatMapOpTest extends OpTestCase { ...@@ -122,7 +131,10 @@ public class FlatMapOpTest extends OpTestCase {
result = exerciseOps(data, s -> DoubleStream.empty()); result = exerciseOps(data, s -> DoubleStream.empty());
assertEquals(0, result.size()); assertEquals(0, result.size());
}
@Test(dataProvider = "DoubleStreamTestData.small", dataProviderClass = DoubleStreamTestDataProvider.class)
public void testDoubleOpsX(String name, TestData.OfDouble data) {
exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).asDoubleStream())); exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).asDoubleStream()));
exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).asDoubleStream())); exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).asDoubleStream()));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册