Révision | ca48c1e303d6f02a790f730eb1bbcb11a32f70ee (tree) |
---|---|
l'heure | 2023-01-26 01:36:03 |
Auteur | miyakawataku |
Commiter | miyakawataku |
make test not dependent on AllocationSet interface
@@ -16,9 +16,6 @@ | ||
16 | 16 | import static org.assertj.core.api.Assertions.assertThat; |
17 | 17 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
18 | 18 | |
19 | -import static org.mockito.Mockito.mock; | |
20 | -import static org.mockito.Mockito.when; | |
21 | - | |
22 | 19 | import org.kink_lang.kink.Val; |
23 | 20 | import org.kink_lang.kink.internal.callstack.Location; |
24 | 21 | import org.kink_lang.kink.internal.callstack.Trace; |
@@ -103,25 +100,31 @@ | ||
103 | 100 | |
104 | 101 | @Test |
105 | 102 | public void load_nullable_stack_lvar() { |
106 | - AllocationSet allocationSet = mock(AllocationSet.class); | |
103 | + ValCaptureAllocationSet allocationSet = new ValCaptureAllocationSet( | |
104 | + Set.of(), | |
105 | + Map.of(), | |
106 | + Set.of(), | |
107 | + List.of(), | |
108 | + List.of( | |
109 | + new LocalVar.Original("X"), | |
110 | + new LocalVar.Original("Y"), | |
111 | + new LocalVar.Original("Sn"))); | |
107 | 112 | LvarAccessGenerator accGen = new FastLvarAccessGenerator( |
108 | 113 | allocationSet, |
109 | 114 | new KeyStrSupplier(), |
110 | 115 | traceAccum); |
111 | 116 | |
112 | - when(allocationSet.get(new LocalVar.Original("Sn"))) | |
113 | - .thenReturn(new Allocation.Stack(42, false)); | |
114 | 117 | var insns = accGen.loadLvar( |
115 | 118 | new LocalVar.Original("Sn"), |
116 | 119 | new Location("f.kn", "x", 0)); |
117 | 120 | assertThat(insns).containsExactly( |
118 | 121 | // (dataStack) |
119 | 122 | InsnsGenerator.LOAD_DATASTACK, |
120 | - // (dataStack 1+42) | |
121 | - new Insn.PushInt(43), | |
122 | - // (dataStack 1+42 argCount) | |
123 | + // (dataStack 1+2) | |
124 | + new Insn.PushInt(3), | |
125 | + // (dataStack 1+2 argCount) | |
123 | 126 | InsnsGenerator.LOAD_ARGCOUNT, |
124 | - // (dataStack 1+42+argCount) | |
127 | + // (dataStack 1+2+argCount) | |
125 | 128 | new Insn.AddInt(), |
126 | 129 | // (lvar) |
127 | 130 | new Insn.InvokeVirtual(Type.getType("Lorg/kink_lang/kink/DataStack;"), |