Skip to content

Commit

Permalink
Adapted test suite to changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kc611 committed Jul 3, 2023
1 parent 7a3b4c2 commit e1097ad
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 5 additions & 5 deletions numba_rvsdg/tests/test_scfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
Expand Down Expand Up @@ -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:
"""
)
Expand Down
2 changes: 2 additions & 0 deletions numba_rvsdg/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand All @@ -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(
Expand Down
15 changes: 13 additions & 2 deletions numba_rvsdg/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e1097ad

Please sign in to comment.