~ chicken-core (chicken-5) 671dd21f5fa98b9ddc6e9dc0ee0e9b62b51025bf


commit 671dd21f5fa98b9ddc6e9dc0ee0e9b62b51025bf
Author:     Kooda <kooda@upyum.com>
AuthorDate: Fri Sep 8 01:46:16 2017 +0200
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Tue Sep 12 21:01:01 2017 +0200

    Add a test case for multiple values handling.
    
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/tests/multiple-values.scm b/tests/multiple-values.scm
new file mode 100644
index 00000000..83274013
--- /dev/null
+++ b/tests/multiple-values.scm
@@ -0,0 +1,22 @@
+(define-syntax assert-fail
+  (syntax-rules ()
+    ((_ exp)
+     (assert (handle-exceptions ex #t exp #f)))))
+
+(define (f x) #t)
+
+;; Relaxed cases
+(assert (f (values 1 2 3)))
+(assert (f (call/cc (lambda (k) (k 1 2 3)))))
+
+;; Strict cases
+(assert-fail (call-with-values (lambda () (values 1 2 3)) f))
+(assert-fail
+  (call-with-values
+    (lambda () (call/cc (lambda (k) (k 1 2 3))))
+    f))
+
+;; Sanity check for strict cases with correct argument count
+(assert (call-with-values (lambda () (values 1)) f))
+(assert (call-with-values (lambda () 1) f))
+(assert (call-with-values (lambda () (call/cc (lambda (k) (k 1)))) f))
diff --git a/tests/runtests.bat b/tests/runtests.bat
index 8ac8b144..2d25a98e 100644
--- a/tests/runtests.bat
+++ b/tests/runtests.bat
@@ -601,6 +601,14 @@ rem this may crash, if the PATH contains a non-matching libchicken.dll on Window
 set PATH=%PATH%;%CD%\tmp xxx %CD%\tmp
 del /f /q /s rev-app rev-app-2 reverser\*.import.* reverser\*.so
 
+echo ======================================== multiple return values tests ...
+%interpret% -s multiple-values.scm
+if errorlevel 1 exit /b 1
+%compile% multiple-values.scm
+if errorlevel 1 exit /b 1
+a.out
+if errorlevel 1 exit /b 1
+
 rem echo ======================================== reinstall tests
 rem currently disabled for windows
 
diff --git a/tests/runtests.sh b/tests/runtests.sh
index 1cce11e6..752e6b74 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -463,4 +463,9 @@ PATH=`pwd`/tmp:$PATH xxx ${TEST_DIR}/tmp
 #PATH=$PATH:${TEST_DIR}/tmp xxx ${TEST_DIR}/tmp
 rm -fr reverser/*.import.* reverser/*.so
 
+echo "======================================== multiple return values tests ..."
+$interpret -s multiple-values.scm
+$compile multiple-values.scm
+./a.out
+
 echo "======================================== done."
Trap