From 832cfda56bedeb728acb94ea3738fd5a081af728 Mon Sep 17 00:00:00 2001
From: "Michael \"Z\" Goddard" <mzgoddard@gmail.com>
Date: Mon, 3 Jun 2019 18:13:41 -0400
Subject: [PATCH] unit test more stepToBranch scenarios

---
 test/unit/engine_sequencer.js | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/test/unit/engine_sequencer.js b/test/unit/engine_sequencer.js
index 2e0657382..b2cd26139 100644
--- a/test/unit/engine_sequencer.js
+++ b/test/unit/engine_sequencer.js
@@ -120,16 +120,40 @@ test('stepToBranch', t => {
     const r = new Runtime();
     const s = new Sequencer(r);
     const th = generateThread(r);
+
+    // Push substack 2 (null).
     s.stepToBranch(th, 2, false);
     t.strictEquals(th.peekStack(), null);
     th.popStack();
+    t.strictEquals(th.peekStackFrame().isLoop, false);
+    // Push substack 1 (null).
     s.stepToBranch(th, 1, false);
     t.strictEquals(th.peekStack(), null);
     th.popStack();
+    t.strictEquals(th.peekStackFrame().isLoop, false);
+    // Push loop substack (null).
+    s.stepToBranch(th, 1, true);
+    t.strictEquals(th.peekStack(), null);
     th.popStack();
+    t.strictEquals(th.peekStackFrame().isLoop, true);
+    // isLoop resets when thread goes to next block.
+    th.goToNextBlock();
+    t.strictEquals(th.peekStackFrame().isLoop, false);
+    th.popStack();
+    // Push substack 1 (not null).
     s.stepToBranch(th, 1, false);
     t.notEquals(th.peekStack(), null);
-    
+    th.popStack();
+    t.strictEquals(th.peekStackFrame().isLoop, false);
+    // Push loop substack (not null).
+    s.stepToBranch(th, 1, true);
+    t.notEquals(th.peekStack(), null);
+    th.popStack();
+    t.strictEquals(th.peekStackFrame().isLoop, true);
+    // isLoop resets when thread goes to next block.
+    th.goToNextBlock();
+    t.strictEquals(th.peekStackFrame().isLoop, false);
+
     t.end();
 });