~ chicken-core (chicken-5) 2d9911abb77674f064f49d25b713e5b3f436c861


commit 2d9911abb77674f064f49d25b713e5b3f436c861
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Fri Jun 25 08:44:55 2010 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Fri Jun 25 08:44:55 2010 +0200

    added dwindtst from slib

diff --git a/distribution/manifest b/distribution/manifest
index 613454a7..d82681cd 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -157,6 +157,8 @@ tests/slatex.sty
 tests/symbolgc-tests.scm
 tests/private-repository-test.scm
 tests/records-and-setters-test.scm
+tests/dwindtst.scm
+tests/dwindtst.expected
 tweaks.scm
 utils.scm
 apply-hack.x86.S
diff --git a/tests/dwindtst.expected b/tests/dwindtst.expected
new file mode 100644
index 00000000..7409bb54
--- /dev/null
+++ b/tests/dwindtst.expected
@@ -0,0 +1,41 @@
+testing escape from thunk1
+visiting:
+thunk1
+testing escape from thunk2
+visiting:
+thunk1
+thunk2
+thunk3
+testing escape from thunk3
+visiting:
+thunk1
+thunk2
+thunk3
+creating continuation thunk
+visiting:
+thunk1
+thunk2
+thunk3
+testing escape from continuation thunk1
+visiting:
+thunk1
+creating continuation thunk
+visiting:
+thunk1
+thunk2
+thunk3
+testing escape from continuation thunk2
+visiting:
+thunk1
+thunk2
+thunk3
+creating continuation thunk
+visiting:
+thunk1
+thunk2
+thunk3
+testing escape from continuation thunk3
+visiting:
+thunk1
+thunk2
+thunk3
diff --git a/tests/dwindtst.scm b/tests/dwindtst.scm
new file mode 100644
index 00000000..088db07d
--- /dev/null
+++ b/tests/dwindtst.scm
@@ -0,0 +1,78 @@
+;;;; "dwindtst.scm", routines for characterizing dynamic-wind.
+;Copyright (C) 1992 Aubrey Jaffer
+;
+;Permission to copy this software, to modify it, to redistribute it,
+;to distribute modified versions, and to use it for any purpose is
+;granted, subject to the following restrictions and understandings.
+;
+;1.  Any copy made of this software must include this copyright notice
+;in full.
+;
+;2.  I have made no warranty or representation that the operation of
+;this software will be error-free, and I am under no obligation to
+;provide any services, by way of maintenance, update, or otherwise.
+;
+;3.  In conjunction with products arising from the use of this
+;material, there shall be no use of my name in any advertising,
+;promotional, or sales literature without prior written consent in
+;each case.
+
+(define (dwtest n)
+  (define cont #f)
+  (display "testing escape from thunk") (display n) (newline)
+  (display "visiting:") (newline)
+  (call-with-current-continuation
+   (lambda (x) (set! cont x)))
+  (if n
+      (dynamic-wind
+       (lambda ()
+	 (display "thunk1") (newline)
+	 (if (eqv? n 1) (let ((ntmp n))
+			  (set! n #f)
+			  (cont ntmp))))
+       (lambda ()
+	 (display "thunk2") (newline)
+	 (if (eqv? n 2) (let ((ntmp n))
+			  (set! n #f)
+			  (cont ntmp))))
+       (lambda ()
+	 (display "thunk3") (newline)
+	 (if (eqv? n 3) (let ((ntmp n))
+			  (set! n #f)
+			  (cont ntmp)))))))
+(define (dwctest n)
+  (define cont #f)
+  (define ccont #f)
+  (display "creating continuation thunk") (newline)
+  (display "visiting:") (newline)
+  (call-with-current-continuation
+   (lambda (x) (set! cont x)))
+  (if n (set! n (- n)))
+  (if n
+      (dynamic-wind
+       (lambda ()
+	 (display "thunk1") (newline)
+	 (if (eqv? n 1) (let ((ntmp n))
+			  (set! n #f)
+			  (cont ntmp))))
+       (lambda ()
+	 (call-with-current-continuation
+	  (lambda (x) (set! ccont x)))
+	 (display "thunk2") (newline)
+	 (if (eqv? n 2) (let ((ntmp n))
+			  (set! n #f)
+			  (cont ntmp))))
+       (lambda ()
+	 (display "thunk3") (newline)
+	 (if (eqv? n 3) (let ((ntmp n))
+			  (set! n #f)
+			  (cont ntmp))))))
+  (cond
+   (n
+    (set! n (- n))
+    (display "testing escape from continuation thunk") (display n) (newline)
+    (display "visiting:") (newline)
+    (ccont #f))))
+
+(dwtest 1) (dwtest 2) (dwtest 3)
+(dwctest 1) (dwctest 2) (dwctest 3)
diff --git a/tests/runtests.sh b/tests/runtests.sh
index 74e0e328..50613244 100644
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -84,6 +84,15 @@ $interpret -s records-and-setters-test.scm
 $compile records-and-setters-test.scm
 ./a.out
 
+echo "======================================== dynamic-wind tests ..."
+$interpret -s dwindtst.scm >dwindtst.out
+diff -bu dwindtst.expected dwindtst.out
+$compile dwindtest.scm
+./a.out >dwindtst.out
+diff -bu dwindtst.expected dwindtst.out
+echo "*** Skipping \"feeley-dynwind\" for now ***"
+# $interpret -s feeley-dynwind.scm
+
 echo "======================================== syntax tests ..."
 $interpret -s syntax-tests.scm
 
@@ -190,8 +199,6 @@ $interpret -s srfi-4-tests.scm
 
 echo "======================================== srfi-18 tests ..."
 $interpret -s srfi-18-tests.scm
-echo "*** Skipping \"feeley-dynwind\" for now ***"
-# $interpret -s feeley-dynwind.scm
 
 echo "======================================== path tests ..."
 $interpret -bnq path-tests.scm
Trap