Pārlūkot izejas kodu

added a test for step ins in both directions wich lead to an endless loop becouse of an unknown error

Kolja Strohm 6 gadi atpakaļ
vecāks
revīzija
b472f8a311

+ 6 - 6
src/processor/PseudoCodeProcessor.java

@@ -67,7 +67,7 @@ public class PseudoCodeProcessor extends Thread {
         return CodeStatus.UNFINISHED;
     }
     
-    public CodeStatus forwardStep()
+    protected CodeStatus forwardStep()
     {
         if( programPointer == null )
             return CodeStatus.FINISHED;
@@ -148,7 +148,7 @@ public class PseudoCodeProcessor extends Thread {
         return status;
     }
     
-    private CodeStatus forwardStepOver()
+    protected CodeStatus forwardStepOver()
     {
         if( programPointer == null )
             return CodeStatus.FINISHED;
@@ -160,7 +160,7 @@ public class PseudoCodeProcessor extends Thread {
         return status;
     }
     
-    private CodeStatus forwardStepOut()
+    protected CodeStatus forwardStepOut()
     {
         if( programPointer == null )
             return CodeStatus.FINISHED;
@@ -189,7 +189,7 @@ public class PseudoCodeProcessor extends Thread {
         return CodeStatus.UNFINISHED;
     }
     
-    private CodeStatus backwardStep()
+    protected CodeStatus backwardStep()
     {
         if( programPointer == null || controlStack.isEmpty() )
             return CodeStatus.FINISHED;
@@ -214,7 +214,7 @@ public class PseudoCodeProcessor extends Thread {
         return status;
     }
     
-    private CodeStatus backwardStepOver()
+    protected CodeStatus backwardStepOver()
     {
         if( programPointer == null )
             return CodeStatus.FINISHED;
@@ -226,7 +226,7 @@ public class PseudoCodeProcessor extends Thread {
         return status;
     }
     
-    private CodeStatus backwardStepOut()
+    protected CodeStatus backwardStepOut()
     {
         if( programPointer == null )
             return CodeStatus.FINISHED;

+ 36 - 0
src/test/StepInProcessor.java

@@ -0,0 +1,36 @@
+package test;
+
+import javax.swing.JFrame;
+
+import graph.LayeredGraphNode;
+import processor.PseudoCodeNode;
+import processor.PseudoCodeProcessor;
+
+public class StepInProcessor extends PseudoCodeProcessor{
+
+    public StepInProcessor(PseudoCodeNode start, LayeredGraphNode graph, JFrame view) {
+        super(start, graph, view);
+    }
+    
+    @Override
+    public void run()
+    {
+        while( true )
+        {
+            CodeStatus status = null;
+            try {
+                status = forwardStep();
+                forwardStep();
+                backwardStep();
+            } catch (Exception e) {
+                e.printStackTrace();
+                return;
+            }
+            if( status == CodeStatus.FINISHED )
+            {
+                System.out.println( "Step Into works in both directions.");
+                return;
+            }
+        }
+    }
+}

+ 26 - 0
src/test/TestProcessor.java

@@ -0,0 +1,26 @@
+package test;
+
+import javax.swing.JFrame;
+import javax.swing.JTree;
+
+import bk.BKNodePlacement;
+import graph.LayeredGraphNode;
+import graph.io.Reader;
+import lib.SimpleNodePlacement;
+import processor.PseudoCodeNode;
+
+public class TestProcessor {
+    
+    public static void main(String[] args) {
+        Reader r = new Reader( "logo.json" );
+        LayeredGraphNode graph = r.readInputGraph();
+        SimpleNodePlacement.placeNodes( graph );
+
+        BKNodePlacement algorithm = new BKNodePlacement();
+        JTree pseudoTree = new JTree();
+        PseudoCodeNode tree = algorithm.createPseudocodeTree( pseudoTree );
+        JFrame frame = new JFrame( "NodeShuffler" );
+        StepInProcessor processor = new StepInProcessor( tree, graph, frame );
+        processor.start();
+    }
+}