class: RegressionTests::BlockTest
authorClaus Gittinger <cg@exept.de>
Fri, 24 May 2013 20:08:09 +0200
changeset 939 77517e3b896b
parent 938 dec392a0a71e
child 940 f0b195f99e55
class: RegressionTests::BlockTest added: #test_unwind2 changed: #test_unwind1
RegressionTests__BlockTest.st
--- a/RegressionTests__BlockTest.st	Fri May 24 19:59:53 2013 +0200
+++ b/RegressionTests__BlockTest.st	Fri May 24 20:08:09 2013 +0200
@@ -229,7 +229,7 @@
                 trace add:22.
             ].
         ] ensure:[
-            trace add:31.
+            trace add:30.
             ensureCount := ensureCount + 1.
         ].
         trace add:40.
@@ -237,7 +237,44 @@
 
     self assert:(callCount == 2).
     self assert:(ensureCount == 2).
-    self assert:(trace asArray = #(10 15 20 21 31 15 20 31 40)).
+    self assert:(trace asArray = #(10 15 20 21 30 15 20 30 40)).
+!
+
+test_unwind2
+    <context: #return>
+
+    |mark trace firstEntry callCount ensureCount kon|
+
+    kon := thisContext.
+    mark isNil ifTrue:[
+        mark := true.
+        trace := OrderedCollection new.
+        firstEntry := true.
+        callCount := ensureCount := 0.
+        trace add:5.
+    ].
+
+    trace add:10.
+
+    [
+        trace add:20.
+        callCount := callCount + 1.
+        firstEntry ifTrue:[
+            trace add:21.
+            firstEntry := false.
+            kon unwindAndRestart.
+            trace add:22.
+        ].
+    ] ensure:[
+        trace add:30.
+        ensureCount := ensureCount + 1.
+    ].
+
+    trace add:40.
+
+    self assert:(callCount == 2).
+    self assert:(ensureCount == 2).
+    self assert:(trace asArray = #(5 10 20 21 30 10 20 30 40)).
 ! !
 
 !BlockTest methodsFor:'varArgBlocks'!