Skip to content
Snippets Groups Projects
test_sfg.py 1.12 KiB
Newer Older
  • Learn to ignore specific revisions
  • Ivar Härnqvist's avatar
    Ivar Härnqvist committed
    from b_asic import SFG
    from b_asic.signal import Signal
    from b_asic.core_operations import Addition, Constant
    from b_asic.special_operations import Input, Output
    
    class TestConstructor:
        def test_outputs_construction(self, operation_tree):
            outp = Output(operation_tree)
            sfg = SFG(outputs=[outp])
    
            assert len(list(sfg.components)) == 7
            assert sfg.input_count == 0
            assert sfg.output_count == 1
    
        def test_signals_construction(self, operation_tree):
            outs = Signal(source=operation_tree.output(0))
            sfg = SFG(output_signals=[outs])
    
            assert len(list(sfg.components)) == 7
            assert sfg.input_count == 0
            assert sfg.output_count == 1
    
        def test_operations_construction(self, operation_tree):
            sfg1 = SFG(operations=[operation_tree])
            sfg2 = SFG(operations=[operation_tree.input(1).signals[0].source.operation])
    
            assert len(list(sfg1.components)) == 5
            assert len(list(sfg2.components)) == 5
            assert sfg1.input_count == 0
            assert sfg2.input_count == 0
            assert sfg1.output_count == 0
            assert sfg2.output_count == 0