diff --git a/numba_rvsdg/tests/test_scfg.py b/numba_rvsdg/tests/test_scfg.py index 09ba383..3d1d9e5 100644 --- a/numba_rvsdg/tests/test_scfg.py +++ b/numba_rvsdg/tests/test_scfg.py @@ -123,7 +123,7 @@ def test_dict_conversion(self): "0": ["1", "2"], "1": ["5"], "2": ["1", "5"], - "3": ["0"], + "3": ["1"], "4": [], "5": ["3", "4"], }, @@ -166,13 +166,13 @@ def test_scfg_iter(self): scfg, _ = SCFG.from_yaml( """ blocks: - '0': + 'basic_block_0': type: basic - '1': + 'basic_block_1': type: basic edges: - '0': ['1'] - '1': [] + 'basic_block_0': ['basic_block_1'] + 'basic_block_1': [] backedges: """ ) diff --git a/numba_rvsdg/tests/test_transforms.py b/numba_rvsdg/tests/test_transforms.py index d42c2e0..4b4ce58 100644 --- a/numba_rvsdg/tests/test_transforms.py +++ b/numba_rvsdg/tests/test_transforms.py @@ -208,6 +208,7 @@ def test_dual_predecessor_and_dual_successor_with_additional_arcs(self): '3': ['0'] '4': [] backedges: + '3': ['0'] """ original_scfg, block_dict = SCFG.from_yaml(original) expected = """ @@ -232,6 +233,7 @@ def test_dual_predecessor_and_dual_successor_with_additional_arcs(self): '4': [] '5': ['3', '4'] backedges: + '3': ['0'] """ expected_scfg, expected_block_dict = SCFG.from_yaml(expected) original_scfg.insert_block( diff --git a/numba_rvsdg/tests/test_utils.py b/numba_rvsdg/tests/test_utils.py index c1f228d..524066d 100644 --- a/numba_rvsdg/tests/test_utils.py +++ b/numba_rvsdg/tests/test_utils.py @@ -2,12 +2,12 @@ import yaml from numba_rvsdg.core.datastructures.scfg import SCFG -from numba_rvsdg.core.datastructures.basic_block import BasicBlock +from numba_rvsdg.core.datastructures.basic_block import BasicBlock, RegionBlock class SCFGComparator(TestCase): def assertSCFGEqual( - self, first_scfg: SCFG, second_scfg: SCFG, head_map=None + self, first_scfg: SCFG, second_scfg: SCFG, head_map=None, exiting=None ): if head_map: # If more than one head the corresponding map needs to be provided @@ -41,14 +41,25 @@ def assertSCFGEqual( assert len(node.jump_targets) == len(second_node.jump_targets) assert len(node.backedges) == len(second_node.backedges) + # If the given block is a egionBlock, then the underlying SCFGs + # for both regions must be equal + if isinstance(node, RegionBlock): + self.assertSCFGEqual( + node.subregion, second_node.subregion, exiting=node.exiting + ) + # Add the jump targets as corresponding nodes in block mapping # dictionary. Since order must be same we can simply add zip # functionality as the correspondence function for nodes for jt1, jt2 in zip(node.jump_targets, second_node.jump_targets): + if node.name == exiting: + continue block_mapping[jt1] = jt2 stack.append(jt1) for be1, be2 in zip(node.backedges, second_node.backedges): + if node.name == exiting: + continue block_mapping[be1] = be2 stack.append(be1)