Skip to content

Commit dbd0807

Browse files
committed
Widening argument types of Promises.all/any/anyStrict/atLeast/atLeastStrict
1 parent 8d3e98f commit dbd0807

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/test/java/net/tascalate/concurrent/PromisesTests.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,41 @@ public void tearDown() {
2121
}
2222

2323
@Test
24-
public void testGenericArgs() {
25-
Promise<List<Number>> p = ttt(BigDecimal.valueOf(10), Long.valueOf(11));
24+
public void testGenericArgsWithList() {
25+
Promise<List<Number>> p = combineWithList(BigDecimal.valueOf(10), Long.valueOf(11));
2626
List<Number> v = p.join();
2727
assertTrue("Fisrt is BigDecimal ", v.get(0) instanceof BigDecimal);
2828
assertTrue("Second is Long ", v.get(1) instanceof Long);
2929
}
3030

31-
<T, U extends T, V extends T> Promise<List<T>> ttt(U a, V b) {
31+
@Test
32+
public void testGenericArgsWithArray() {
33+
Promise<List<Number>> p = combineWithArray1(BigDecimal.valueOf(10), Long.valueOf(11));
34+
List<Number> v = p.join();
35+
assertTrue("Fisrt is BigDecimal ", v.get(0) instanceof BigDecimal);
36+
assertTrue("Second is Long ", v.get(1) instanceof Long);
37+
}
38+
39+
40+
<T, U extends T, V extends T> Promise<List<T>> combineWithList(U a, V b) {
3241
List<Promise<T>> promises = new ArrayList<>();
3342
promises.add(Promises.success(a));
3443
promises.add(Promises.success(b));
3544
Promise<List<T>> all = Promises.all(promises);
3645
return all;
3746
}
47+
48+
<T, U extends T, V extends T> Promise<List<T>> combineWithArray1(U a, V b) {
49+
@SuppressWarnings("unchecked")
50+
Promise<T>[] promises = new Promise[2];
51+
promises[0] = Promises.success(a);
52+
promises[1] = Promises.success(b);
53+
Promise<List<T>> all = Promises.all(promises);
54+
return all;
55+
}
56+
57+
<T, U extends T, V extends T> Promise<List<T>> combineWithArray2(U a, V b) {
58+
Promise<List<T>> all = Promises.all(Promises.success(a), Promises.success(b));
59+
return all;
60+
}
3861
}

0 commit comments

Comments
 (0)