@@ -46,6 +46,29 @@ public void testSimplification() {
4646
4747 }
4848
49+ @ Test
50+ public void testSimplificationPerCallHints () {
51+ // make sure we can find the Op when adaptation is allowed
52+ Hints hints = new DefaultHints ();
53+ hints .setHint (Simplification .ALLOWED );
54+ @ SuppressWarnings ("unused" )
55+ Function <Integer [], Integer []> adaptable = ops .op (
56+ "test.simplification.hints" ).inType (Integer [].class ).outType (
57+ Integer [].class ).function (hints );
58+ // make sure we cannot find the Op when adaptation is not allowed
59+ hints .setHint (Simplification .FORBIDDEN );
60+ try {
61+ ops .op ("test.simplification.hints" ).inType (Integer [].class ).outType (
62+ Integer [].class ).function (hints );
63+ throw new IllegalStateException (
64+ "Simplification is forbidden - this op call should not match!" );
65+ }
66+ catch (IllegalArgumentException e ) {
67+ assertTrue (e .getCause () instanceof OpMatchingException );
68+ }
69+
70+ }
71+
4972 @ OpHints (hints = { Simplification .FORBIDDEN })
5073 @ OpField (names = "test.simplification.unsimplifiable" )
5174 public final Function <Double [], Double []> nonAdaptableOp = (
@@ -76,4 +99,28 @@ public void testUnsimplifiableOp() {
7699
77100 }
78101
102+ @ Test
103+ public void testUnsimplifiableOpPerCallHints () {
104+ // make sure we can find the Op when adaptation is allowed
105+ Hints hints = new DefaultHints ();
106+ hints .setHint (Simplification .ALLOWED );
107+ @ SuppressWarnings ("unused" )
108+ Function <Double [], Double []> adaptable = ops .op (
109+ "test.simplification.unsimplifiable" ).inType (Double [].class ).outType (
110+ Double [].class ).function (hints );
111+ // make sure that we cannot match the Op via adaptation even when
112+ // simplification
113+ // is allowed (since it declares itself to be unsimplifiable)
114+ try {
115+ ops .op ("test.simplification.unsimplifiable" ).inType (Integer [].class )
116+ .outType (Integer [].class ).function (hints );
117+ throw new IllegalStateException (
118+ "The only relevant Op is not simplifiable - this op call should not match!" );
119+ }
120+ catch (IllegalArgumentException e ) {
121+ assertTrue (e .getCause () instanceof OpMatchingException );
122+ }
123+
124+ }
125+
79126}
0 commit comments