OpenJDK / lambda / lambda / jdk
changeset 8350:88874f4dccae
fix library path
author | mduigou |
---|---|
date | Mon, 22 Apr 2013 14:48:07 -0700 |
parents | a922c7c6b613 |
children | 4202bdab3c2d |
files | test/java/util/List/SortAndReplaceAllTest.java |
diffstat | 1 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/test/java/util/List/SortAndReplaceAllTest.java Mon Apr 22 13:55:28 2013 -0700 +++ b/test/java/util/List/SortAndReplaceAllTest.java Mon Apr 22 14:48:07 2013 -0700 @@ -25,7 +25,7 @@ * @test * @summary test for List default methods replaceAll() and sort(); * @(#) SortAndReplaceAllTest.java - * @library ../../ + * @library ../ * @author Tristan Yan * @run testng SortAndReplaceAllTest */ @@ -50,13 +50,13 @@ public class SortAndReplaceAllTest <T extends List<Integer>>{ protected Class<T> typeObject; - + protected boolean hasIni; - + protected int initSize; protected final static int START = -1 << 6; - + protected final static int END = 1 << 6; protected final static Random rand = new Random(System.currentTimeMillis()); @@ -69,7 +69,7 @@ (Class<Stack<Integer>>)(Class<?>)(Stack.class), (Class<Vector<Integer>>)(Class<?>)(Vector.class) }; - + @SuppressWarnings({"rawtypes", "unchecked"}) protected static Class[] capacityConstructorClazz = { (Class<ArrayList<Integer>>)(Class<?>)(ArrayList.class), @@ -84,14 +84,14 @@ this.initSize = initSizes[0]; } } - + private List<Integer> generateList(int start, int end, int size) throws Exception{ - List<Integer> list = hasIni ? + List<Integer> list = hasIni ? (List<Integer>)LambdaUtilities.create(typeObject, initSize) : (List<Integer>)LambdaUtilities.create(typeObject); for(int i = 0; i < size; i++) { - int element = start + rand.nextInt(end - start); + int element = start + rand.nextInt(end - start); list.add(element); } return list; @@ -100,13 +100,13 @@ protected List<Integer> generateList(int start, int end) throws Exception{ return generateList(start, end, end - start); } - + @Factory @SuppressWarnings({"rawtypes", "unchecked"}) public static Object[] create(){ List<SortAndReplaceAllTest> result = new ArrayList<>(); Stream<Class> stream1 = Arrays.stream(defaultConstructorClazz); - Stream<Class> stream2 = Arrays.stream(capacityConstructorClazz); + Stream<Class> stream2 = Arrays.stream(capacityConstructorClazz); stream1.forEach(clazz -> result.add(new SortAndReplaceAllTest(clazz))); stream2.forEach(clazz -> result.add(new SortAndReplaceAllTest(clazz, END - START + rand.nextInt(END - START)))); @@ -116,15 +116,15 @@ @Test public void testReplaceAll() throws Exception { List<Integer> list = generateList(START, END); - List<Integer> listCloned = hasIni ? + List<Integer> listCloned = hasIni ? (List<Integer>)LambdaUtilities.create(typeObject, initSize) : (List<Integer>)LambdaUtilities.create(typeObject); listCloned.addAll(list); EnumSet<LambdaUtilities.IntOp> set = EnumSet.allOf(LambdaUtilities.IntOp.class); - LambdaUtilities.IntOp[] ops = new LambdaUtilities.IntOp[set.size()]; + LambdaUtilities.IntOp[] ops = new LambdaUtilities.IntOp[set.size()]; set.toArray(ops); LambdaUtilities.IntOp op = ops[rand.nextInt(ops.length)]; - int value = START + rand.nextInt(END - START); + int value = START + rand.nextInt(END - START); if( op == LambdaUtilities.IntOp.DIVIDE || op == LambdaUtilities.IntOp.MOD) { while(value == 0) { value = START + rand.nextInt(END - START); @@ -133,7 +133,7 @@ list.replaceAll(LambdaUtilities.opIntegerUnaryOperator(op, value)); checkReplace(listCloned, list, op, value); } - + @Test @SuppressWarnings({"rawtypes", "unchecked"}) public void testSort() throws Exception{ @@ -151,8 +151,8 @@ testComparator((Comparator<Integer>)csit.next()); } } - - private void checkReplace(List<Integer> orig, List<Integer> replaced, + + private void checkReplace(List<Integer> orig, List<Integer> replaced, LambdaUtilities.IntOp op, int value) { assertEquals(orig.size(), replaced.size()); for(int index = 0; index < orig.size(); index++) { @@ -160,7 +160,7 @@ case ADD: assertTrue(orig.get(index) + value == replaced.get(index)); break; - case SUBTRACT: + case SUBTRACT: assertTrue(orig.get(index) - value == replaced.get(index)); break; case MULTIPLY: @@ -178,7 +178,7 @@ private void testComparator(Comparator<Integer> c) throws Exception { List<Integer> list = generateList(START, END); - List<Integer> listCloned = hasIni ? + List<Integer> listCloned = hasIni ? (List<Integer>)LambdaUtilities.create(typeObject, initSize) : (List<Integer>)LambdaUtilities.create(typeObject); listCloned.addAll(list);