Read complex numbers where both parts are inexact decimals
[bpt/guile.git] / test-suite / tests / continuations.test
1 ;;;; -*- scheme -*-
2 ;;;; continuations.test --- test suite for continutations
3 ;;;;
4 ;;;; Copyright (C) 2003, 2006 Free Software Foundation, Inc.
5 ;;;;
6 ;;;; This library is free software; you can redistribute it and/or
7 ;;;; modify it under the terms of the GNU Lesser General Public
8 ;;;; License as published by the Free Software Foundation; either
9 ;;;; version 3 of the License, or (at your option) any later version.
10 ;;;;
11 ;;;; This library is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;;; Lesser General Public License for more details.
15 ;;;;
16 ;;;; You should have received a copy of the GNU Lesser General Public
17 ;;;; License along with this library; if not, write to the Free Software
18 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 (define-module (test-suite test-continuations)
21 :use-module (test-suite lib))
22
23 (define (block-reentry body)
24 (let ((active #f))
25 (dynamic-wind
26 (lambda ()
27 (if active
28 (throw 'no-reentry)))
29 (lambda ()
30 (set! active #t)
31 (body))
32 (lambda () #f))))
33
34 (define (catch-tag body)
35 (catch #t
36 body
37 (lambda (tag . args) tag)))
38
39 (define (check-cont)
40 (catch-tag
41 (lambda ()
42 (block-reentry (lambda () (call/cc identity))))))
43
44 (define (dont-crash-please)
45 (let ((k (check-cont)))
46 (if (procedure? k)
47 (k 12)
48 k)))
49
50 (with-test-prefix "continuations"
51
52 (pass-if "throwing to a rewound catch context"
53 (eq? (dont-crash-please) 'no-reentry))
54
55 (with-debugging-evaluator
56
57 (pass-if "make a stack from a continuation"
58 (stack? (call-with-current-continuation make-stack)))
59
60 (pass-if "get a continuation's stack ID"
61 (let ((id (call-with-current-continuation stack-id)))
62 (or (boolean? id) (symbol? id))))
63
64 (pass-if "get a continuation's innermost frame"
65 (pair? (call-with-current-continuation last-stack-frame))))
66
67 )