From 5ca593d6f59829b71f5cd82ea5caedcab13824c7 Mon Sep 17 00:00:00 2001
From: Kevin <Kevin>
Date: Sun, 10 May 2020 10:59:32 +0200
Subject: [PATCH] Added some tests and function definition

---
 b_asic/signal_flow_graph.py |  6 ++++++
 test/test_sfg.py            | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py
index 6483cfc1..00269bfc 100644
--- a/b_asic/signal_flow_graph.py
+++ b/b_asic/signal_flow_graph.py
@@ -543,6 +543,12 @@ class SFG(AbstractOperation):
         # Recreate the newly coupled SFG so that all attributes are correct.
         return sfg_copy()
 
+    def explode(self) -> Tuple[Sequence[Signal, Sequence[Signal]], Sequence[Tuple[Signal, Sequence[Signal]]]:
+    """Destroy the sfg by making it unusable in the future and 
+    return all of the intermidetry operations, the input operations and the output operations.
+    """
+    return
+
     def _evaluate_source(self, src: OutputPort, results: MutableOutputMap, registers: MutableRegisterMap, prefix: str) -> Number:
         src_prefix = prefix
         if src_prefix:
diff --git a/test/test_sfg.py b/test/test_sfg.py
index 5f867395..976a5984 100644
--- a/test/test_sfg.py
+++ b/test/test_sfg.py
@@ -319,6 +319,22 @@ class TestInsertComponent:
         assert _sfg.find_by_name("bfly2")[0].input(0).signals[0].source.operation is _sfg.find_by_name("n_bfly")[0]
         assert _sfg.find_by_name("bfly2")[0].input(1).signals[0].source.operation is _sfg.find_by_name("n_bfly")[0]
 
+class TestExplode:
+    def test_correct_lengths(self, large_operation_tree):
+        sfg = SFG(outputs=[Output(large_operation_tree)])
+        operations, inputs, outputs = sfg.explode()
+        assert len(operations) == 3
+        assert len(inputs) == 4
+        assert len(outputs) == 1
+
+    def test_sfg_unusable(self, large_operation_tree):
+        sfg = SFG(outputs=[Output(large_operation_tree)])
+        sfg.explode()
+        assert sfg is None
+
+    def test_functions_of_sfg_used(self):
+        with pytest.raises(AssertionError):
+            pass
         
 class TestFindComponentsWithTypeName:
     def test_mac_components(self):
-- 
GitLab