Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java @ 16756:5148aab962af
Truffle-DSL: updated tests for the new generation layout.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 15:53:05 +0200 |
parents | 79041ab43660 |
children | 9f38d222fa6c |
comparison
equal
deleted
inserted
replaced
16755:bd28da642eea | 16756:5148aab962af |
---|---|
46 } | 46 } |
47 | 47 |
48 @NodeAssumptions("assumption") | 48 @NodeAssumptions("assumption") |
49 abstract static class SingleAssumptionNode extends ValueNode { | 49 abstract static class SingleAssumptionNode extends ValueNode { |
50 | 50 |
51 @Specialization(order = 0, assumptions = "assumption") | 51 @Specialization(assumptions = "assumption") |
52 int doInt() { | 52 int do2() { |
53 return 42; | 53 return 42; |
54 } | 54 } |
55 | 55 |
56 @Specialization | 56 @Generic |
57 Object doObject() { | 57 Object doFallBack() { |
58 return "42"; | 58 return "42"; |
59 } | 59 } |
60 | |
60 } | 61 } |
61 | 62 |
62 @Test | 63 @Test |
63 public void testMultipleAssumption() { | 64 public void testMultipleAssumption() { |
64 Assumption assumption1 = Truffle.getRuntime().createAssumption(); | 65 Assumption assumption1 = Truffle.getRuntime().createAssumption(); |
65 Assumption assumption2 = Truffle.getRuntime().createAssumption(); | 66 Assumption assumption2 = Truffle.getRuntime().createAssumption(); |
66 TestRootNode<?> root = TestHelper.createRoot(MultipleAssumptionsNodeFactory.getInstance(), assumption1, assumption2); | 67 TestRootNode<?> root = TestHelper.createRoot(MultipleAssumptionsNodeFactory.getInstance(), assumption1, assumption2); |
67 | 68 |
68 Assert.assertEquals(42, TestHelper.executeWith(root)); | 69 Assert.assertEquals(42, TestHelper.executeWith(root)); |
69 assumption2.invalidate(); | 70 assumption2.invalidate(); |
71 Assert.assertEquals("41", TestHelper.executeWith(root)); | |
72 assumption1.invalidate(); | |
70 Assert.assertEquals("42", TestHelper.executeWith(root)); | 73 Assert.assertEquals("42", TestHelper.executeWith(root)); |
71 assumption1.invalidate(); | |
72 Assert.assertEquals("43", TestHelper.executeWith(root)); | |
73 } | 74 } |
74 | 75 |
75 @NodeAssumptions({"assumption1", "assumption2"}) | 76 @NodeAssumptions({"assumption1", "assumption2"}) |
76 abstract static class MultipleAssumptionsNode extends ValueNode { | 77 abstract static class MultipleAssumptionsNode extends ValueNode { |
77 | 78 |
80 return 42; | 81 return 42; |
81 } | 82 } |
82 | 83 |
83 @Specialization(assumptions = "assumption1") | 84 @Specialization(assumptions = "assumption1") |
84 Object doObject() { | 85 Object doObject() { |
85 return "42"; | 86 return "41"; |
86 } | 87 } |
87 | 88 |
88 @Generic | 89 @Generic |
89 Object doGeneric() { | 90 Object doFallBack() { |
90 return "43"; | 91 return "42"; |
91 } | 92 } |
92 } | 93 } |
93 | 94 |
94 @Test | 95 @Test |
95 public void testDerivedAssumption() { | 96 public void testDerivedAssumption() { |
105 } | 106 } |
106 | 107 |
107 @NodeAssumptions({"additionalAssumption"}) | 108 @NodeAssumptions({"additionalAssumption"}) |
108 abstract static class DerivedAssumptionNode extends SingleAssumptionNode { | 109 abstract static class DerivedAssumptionNode extends SingleAssumptionNode { |
109 | 110 |
110 @Specialization(order = 1, assumptions = "additionalAssumption") | 111 @Specialization(assumptions = "additionalAssumption") |
111 int doIntDerived() { | 112 int doIntDerived() { |
112 return 43; | 113 return 43; |
113 } | 114 } |
115 | |
114 } | 116 } |
115 | 117 |
116 @Test | 118 @Test |
117 public void testDerivedAssumptionRedeclared() { | 119 public void testDerivedAssumptionRedeclared() { |
118 Assumption additionalAssumption = Truffle.getRuntime().createAssumption(); | 120 Assumption additionalAssumption = Truffle.getRuntime().createAssumption(); |
127 } | 129 } |
128 | 130 |
129 @NodeAssumptions({"additionalAssumption", "assumption"}) | 131 @NodeAssumptions({"additionalAssumption", "assumption"}) |
130 abstract static class DerivedAssumptionRedeclaredNode extends SingleAssumptionNode { | 132 abstract static class DerivedAssumptionRedeclaredNode extends SingleAssumptionNode { |
131 | 133 |
132 @Specialization(order = 1, assumptions = "additionalAssumption") | 134 @Specialization(assumptions = "additionalAssumption") |
133 int doIntDerived() { | 135 int doIntDerived() { |
134 return 43; | 136 return 43; |
135 } | 137 } |
136 | 138 |
137 } | 139 } |