Skip to content
Snippets Groups Projects
Commit ab02a00c authored by Kevin Scott's avatar Kevin Scott
Browse files

Added fixture for looping addition tree and removed some unnecessary imports

parent 4ea9e554
No related branches found
No related tags found
2 merge requests!7Resolve "Operation Traversing",!4Operation Tree Traversing
This commit is part of merge request !4. Comments created here will be created in the context of that merge request.
......@@ -46,4 +46,13 @@ def addition_tree():
add_oper = Addition()
create_operation(Constant, add_oper, 0, value=2)
create_operation(Constant, add_oper, 1, value=3)
return add_oper
\ No newline at end of file
return add_oper
@pytest.fixture
def looping_addition_tree(addition_tree):
add_oper_signal_source = SignalSource(addition_tree, 0)
add_oper_signal_dest = SignalDestination(addition_tree, 0)
add_oper_signal = Signal(add_oper_signal_source, add_oper_signal_dest)
addition_tree._output_ports[0].connect(add_oper_signal)
addition_tree._input_ports[0].connect(add_oper_signal)
return addition_tree
\ No newline at end of file
from b_asic.core_operations import Constant, Addition
from b_asic.signal import Signal, SignalSource, SignalDestination
from b_asic.port import InputPort, OutputPort
from b_asic.traverse_tree import Traverse
import pytest
......@@ -26,12 +24,7 @@ def test_traverse_type(large_operation_tree):
assert len(traverse.traverse(Addition)) == 3
assert len(traverse.traverse(Constant)) == 4
def test_traverse_loop(addition_tree):
def test_traverse_loop(looping_addition_tree):
"""Traverse two operations coupled to eachother in a loop."""
add_oper_signal_source = SignalSource(addition_tree, 0)
add_oper_signal_dest = SignalDestination(addition_tree, 0)
add_oper_signal = Signal(add_oper_signal_source, add_oper_signal_dest)
addition_tree._output_ports[0].connect(add_oper_signal)
addition_tree._input_ports[0].connect(add_oper_signal)
traverse = Traverse(addition_tree)
traverse = Traverse(looping_addition_tree)
assert len(traverse.traverse()) == 2
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment