Skip to content

Commit f04eeb9

Browse files
committed
Adapted tests to basic block changes
1 parent 7ce552e commit f04eeb9

File tree

6 files changed

+23
-33
lines changed

6 files changed

+23
-33
lines changed

numba_rvsdg/tests/test_byteflow.py

-5
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def test_constructor(self):
115115
begin=0,
116116
end=8,
117117
_jump_targets=(),
118-
backedges=(),
119118
)
120119
self.assertEqual(block.name, "python_bytecode_block_0")
121120
self.assertEqual(block.begin, 0)
@@ -134,7 +133,6 @@ def test_is_jump_target(self):
134133
_jump_targets=(
135134
name_gen.new_block_name(block_names.PYTHON_BYTECODE),
136135
),
137-
backedges=(),
138136
)
139137
self.assertEqual(block.jump_targets, ("python_bytecode_block_1",))
140138
self.assertFalse(block.is_exiting)
@@ -146,7 +144,6 @@ def test_get_instructions(self):
146144
begin=0,
147145
end=8,
148146
_jump_targets=(),
149-
backedges=(),
150147
)
151148
expected = [
152149
Instruction(
@@ -243,7 +240,6 @@ def test_build_basic_blocks(self):
243240
begin=0,
244241
end=10,
245242
_jump_targets=(),
246-
backedges=(),
247243
)
248244
}
249245
)
@@ -267,7 +263,6 @@ def test_from_bytecode(self):
267263
begin=0,
268264
end=10,
269265
_jump_targets=(),
270-
backedges=(),
271266
)
272267
}
273268
)

numba_rvsdg/tests/test_figures.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def test_figure_3(self):
440440
flow = FlowInfo.from_bytecode(bc)
441441
scfg = flow.build_basicblocks()
442442
byteflow = ByteFlow(bc=bc, scfg=scfg)
443-
byteflow = byteflow.restructure()
443+
byteflow.restructure()
444444

445445
x, _ = SCFG.from_yaml(fig_3_yaml)
446446
self.assertSCFGEqual(x, byteflow.scfg)
@@ -473,7 +473,11 @@ def test_figure_4(self):
473473
flow = FlowInfo.from_bytecode(bc)
474474
scfg = flow.build_basicblocks()
475475
byteflow = ByteFlow(bc=bc, scfg=scfg)
476-
byteflow = byteflow.restructure()
476+
byteflow.restructure()
477477

478478
x, _ = SCFG.from_yaml(fig_4_yaml)
479479
self.assertSCFGEqual(x, byteflow.scfg)
480+
481+
482+
x = TestBahmannFigures()
483+
x.test_figure_3()

numba_rvsdg/tests/test_scfg.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,14 @@ def foo(n):
192192

193193
def test_concealed_region_view_iter(self):
194194
flow = ByteFlow.from_bytecode(self.foo)
195-
restructured = flow._restructure_loop()
195+
flow._restructure_loop()
196196
expected = [
197197
("python_bytecode_block_0", PythonBytecodeBlock),
198198
("loop_region_0", RegionBlock),
199199
("python_bytecode_block_3", PythonBytecodeBlock),
200200
]
201201
received = list(
202-
(
203-
(k, type(v))
204-
for k, v in restructured.scfg.concealed_region_view.items()
205-
)
202+
((k, type(v)) for k, v in flow.scfg.concealed_region_view.items())
206203
)
207204
self.assertEqual(expected, received)
208205

numba_rvsdg/tests/test_simulate.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# flow = ByteFlow.from_bytecode(foo)
66
# #pprint(flow.scfg)
7-
# flow = flow.restructure()
7+
# flow.restructure()
88
# #pprint(flow.scfg)
99
# # pprint(rtsflow.scfg)
1010
# ByteFlowRenderer().render_byteflow(flow).view()
@@ -42,7 +42,7 @@ def foo(x):
4242
return c
4343

4444
flow = ByteFlow.from_bytecode(foo)
45-
flow = flow.restructure()
45+
flow.restructure()
4646

4747
# if case
4848
self._run(foo, flow, {"x": 1})
@@ -57,7 +57,7 @@ def foo(x):
5757
return c
5858

5959
flow = ByteFlow.from_bytecode(foo)
60-
flow = flow.restructure()
60+
flow.restructure()
6161

6262
# loop bypass case
6363
self._run(foo, flow, {"x": 0})
@@ -76,7 +76,7 @@ def foo(x):
7676
return c
7777

7878
flow = ByteFlow.from_bytecode(foo)
79-
flow = flow.restructure()
79+
flow.restructure()
8080

8181
# loop bypass case
8282
self._run(foo, flow, {"x": 0})
@@ -95,7 +95,7 @@ def foo(x):
9595
return c
9696

9797
flow = ByteFlow.from_bytecode(foo)
98-
flow = flow.restructure()
98+
flow.restructure()
9999

100100
# loop bypass case
101101
self._run(foo, flow, {"x": 0})
@@ -119,7 +119,7 @@ def foo(x):
119119
return c
120120

121121
flow = ByteFlow.from_bytecode(foo)
122-
flow = flow.restructure()
122+
flow.restructure()
123123

124124
# no loop
125125
self._run(foo, flow, {"x": 0})
@@ -143,7 +143,7 @@ def foo(x):
143143
return c
144144

145145
flow = ByteFlow.from_bytecode(foo)
146-
flow = flow.restructure()
146+
flow.restructure()
147147

148148
# loop bypass
149149
self._run(foo, flow, {"x": 0})
@@ -159,7 +159,7 @@ def foo(x, y):
159159
return (x > 0 and x < 10) or (y > 0 and y < 10)
160160

161161
flow = ByteFlow.from_bytecode(foo)
162-
flow = flow.restructure()
162+
flow.restructure()
163163

164164
self._run(foo, flow, {"x": 5, "y": 5})
165165

@@ -173,7 +173,7 @@ def foo(s, e):
173173
return c
174174

175175
flow = ByteFlow.from_bytecode(foo)
176-
flow = flow.restructure()
176+
flow.restructure()
177177

178178
# no looping
179179
self._run(foo, flow, {"s": 0, "e": 0})
@@ -190,5 +190,5 @@ def foo(s, e):
190190
self._run(foo, flow, {"s": 23, "e": 28})
191191

192192

193-
if __name__ == "__main__":
194-
unittest.main()
193+
# if __name__ == "__main__":
194+
# unittest.main()

numba_rvsdg/tests/test_transforms.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ def test_backedge_not_exiting(self):
756756
'1': ['2', '5']
757757
'2': ['6']
758758
'3': []
759-
'4': ['1', '3']
759+
'4': ['3', '1']
760760
'5': ['4']
761761
'6': ['4']
762762
backedges:
@@ -810,7 +810,7 @@ def test_multi_back_edge_with_backedge_from_header(self):
810810
'1': ['5', '2']
811811
'2': ['6', '7']
812812
'3': []
813-
'4': ['1', '3']
813+
'4': ['3', '1']
814814
'5': ['4']
815815
'6': ['4']
816816
'7': ['4']
@@ -876,7 +876,7 @@ def test_double_exit(self):
876876
'2': ['3', '6']
877877
'3': ['7', '8']
878878
'4': []
879-
'5': ['1', '4']
879+
'5': ['4', '1']
880880
'6': ['5']
881881
'7': ['5']
882882
'8': ['5']

numba_rvsdg/tests/test_utils.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,12 @@ def assertSCFGEqual(
6565
# Add the jump targets as corresponding nodes in block mapping
6666
# dictionary. Since order must be same we can simply add zip
6767
# functionality as the correspondence function for nodes
68-
for jt1, jt2 in zip(node.jump_targets, second_node.jump_targets):
68+
for jt1, jt2 in zip(node._jump_targets, second_node._jump_targets):
6969
if node.name == exiting:
7070
continue
7171
block_mapping[jt1] = jt2
7272
stack.append(jt1)
7373

74-
for be1, be2 in zip(node.backedges, second_node.backedges):
75-
if node.name == exiting:
76-
continue
77-
block_mapping[be1] = be2
78-
stack.append(be1)
79-
8074
def assertYAMLEqual(
8175
self, first_yaml: SCFG, second_yaml: SCFG, head_map: dict
8276
):

0 commit comments

Comments
 (0)