Skip to content

Commit 9949dfd

Browse files
committed
MatchingUtilsTest: enable working tests
There is only one failing assertion. This commit narrows the scope of the TODO accordingly.
1 parent 8b65648 commit 9949dfd

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

scijava-ops-engine/src/test/java/org/scijava/ops/engine/matcher/MatchingUtilsTest.java renamed to scijava-ops-engine/src/test/java/org/scijava/ops/engine/matcher/impl/MatchingUtilsTest.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* #L%
2828
*/
2929

30-
package org.scijava.ops.engine.matcher;
30+
package org.scijava.ops.engine.matcher.impl;
3131

3232
import static org.junit.jupiter.api.Assertions.assertThrows;
3333
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -44,7 +44,6 @@
4444

4545
import org.junit.jupiter.api.Assertions;
4646
import org.junit.jupiter.api.Test;
47-
import org.scijava.ops.engine.matcher.impl.MatchingUtils;
4847
import org.scijava.types.Nil;
4948
import org.scijava.types.Types;
5049
import org.scijava.types.infer.GenericAssignability;
@@ -527,29 +526,31 @@ class Thing<T> {}
527526
class StrangeThing<N extends Number, T> extends Thing<T> {}
528527

529528
/**
530-
* {@link MatchingUtils#checkGenericOutputsAssignability(Type[], Type[], HashMap)}
531-
* not yet fully implemented. If this is done, all the tests below should not
532-
* fail.
529+
* Tests {@link MatchingUtils#checkGenericOutputsAssignability(Type[], Type[], HashMap)}.
533530
*/
534531
@Test
535532
public <N> void testOutputAssignability() {
536-
// Nil<N> n = new Nil<N>() {};
537-
// Nil<List<N>> ln = new Nil<List<N>>() {};
538-
// Nil<List<? extends Number>> lWildNum = new Nil<List<? extends Number>>() {};
539-
// Nil<List<Number>> lNum = new Nil<List<Number>>() {};
540-
// Nil<List<?>> lwild = new Nil<List<?>>() {};
541-
//
542-
// HashMap<TypeVariable<?>, TypeVarInfo> typeBounds = new HashMap<>();
543-
// assertTrue(-1 == Types.isApplicable(new Type[]{Integer.class}, new Type[]{n.type()}, typeBounds));
544-
// Type[] toOuts = new Type[]{lWildNum.type()};
545-
// Type[] fromOuts = new Type[]{ln.type()};
546-
// assertTrue(-1 == MatchingUtils.checkGenericOutputsAssignability(fromOuts, toOuts, typeBounds));
547-
//
548-
// toOuts = new Type[]{lNum.type()};
549-
// assertTrue(-1 == MatchingUtils.checkGenericOutputsAssignability(fromOuts, toOuts, typeBounds));
550-
//
551-
// toOuts = new Type[]{lwild.type()};
552-
// assertTrue(-1 == MatchingUtils.checkGenericOutputsAssignability(fromOuts, toOuts, typeBounds));
533+
Nil<N> n = new Nil<N>() {};
534+
Nil<List<N>> ln = new Nil<List<N>>() {};
535+
Nil<List<? extends Number>> lWildNum = new Nil<List<? extends Number>>() {};
536+
Nil<List<Number>> lNum = new Nil<List<Number>>() {};
537+
Nil<List<?>> lwild = new Nil<List<?>>() {};
538+
539+
HashMap<TypeVariable<?>, Types.TypeVarInfo> typeBounds = new HashMap<>();
540+
assertTrue(-1 == Types.isApplicable(new Type[]{Integer.class}, new Type[]{n.type()}, typeBounds));
541+
Type[] toOuts = new Type[]{lWildNum.type()};
542+
Type[] fromOuts = new Type[]{ln.type()};
543+
assertTrue(-1 == MatchingUtils.checkGenericOutputsAssignability(fromOuts, toOuts, typeBounds));
544+
545+
toOuts = new Type[]{lNum.type()};
546+
assertTrue(-1 == MatchingUtils.checkGenericOutputsAssignability(fromOuts, toOuts, typeBounds));
547+
548+
toOuts = new Type[]{lwild.type()};
549+
assertTrue(-1 == MatchingUtils.checkGenericOutputsAssignability(fromOuts, toOuts, typeBounds));
550+
551+
// TODO: Investigate how to finish implementing
552+
// checkGenericOutputAssignability properly,
553+
// such that the following test can pass.
553554
//
554555
// typeBounds = new HashMap<>();
555556
// assertTrue(-1 == Types.isApplicable(new Type[]{String.class}, new Type[]{n.type()}, typeBounds));

0 commit comments

Comments
 (0)