traced the bug to an off-by-one, as usual...
This commit is contained in:
parent
7751813bde
commit
cfdbbfaeaa
|
@ -70,9 +70,10 @@ var testArgument = function(expectedTypeName,
|
|||
|
||||
var captureControl = function(MACHINE, skip, tag) {
|
||||
var i;
|
||||
for (i = MACHINE.control.length - skip - 1; i >= 0; i--) {
|
||||
for (i = MACHINE.control.length - 1 - skip; i >= 0; i--) {
|
||||
if (MACHINE.control[i].tag === tag) {
|
||||
return MACHINE.control.slice(i, MACHINE.control.length - skip);
|
||||
return MACHINE.control.slice(i + 1,
|
||||
MACHINE.control.length - skip);
|
||||
}
|
||||
}
|
||||
raise(new Error("captureControl: unable to find tag " + tag));
|
||||
|
@ -85,7 +86,7 @@ var restoreControl = function(MACHINE, tag) {
|
|||
if (MACHINE.control[i].tag === tag) {
|
||||
MACHINE.control =
|
||||
MACHINE.control.slice(0, i+1).concat(
|
||||
MACHINE.env[MACHINE.env.length - 1].slice(0));
|
||||
MACHINE.env[MACHINE.env.length - 1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,16 +69,6 @@ EOF
|
|||
|
||||
|
||||
|
||||
(test '(begin (define program (lambda ()
|
||||
(let ((y (call/cc (lambda (c) c))))
|
||||
(display 1)
|
||||
(call/cc (lambda (c) (y c)))
|
||||
(display 2)
|
||||
(call/cc (lambda (c) (y c)))
|
||||
(display 3))))
|
||||
(program))
|
||||
"11213")
|
||||
|
||||
|
||||
(test '(display 42)
|
||||
"42")
|
||||
|
@ -228,6 +218,19 @@ EOF
|
|||
(displayln (tak 18 12 6)))
|
||||
"7\n")
|
||||
|
||||
|
||||
|
||||
(test '(begin (displayln (+ 42 (call/cc (lambda (k) 3)))) )
|
||||
"45\n")
|
||||
|
||||
|
||||
(test '(begin (displayln (+ 42 (call/cc (lambda (k) (k 100) 3)))) )
|
||||
"142\n")
|
||||
|
||||
(test '(begin (displayln (+ 42 (call/cc (lambda (k) 100 (k 3))))) )
|
||||
"45\n")
|
||||
|
||||
|
||||
(test '(begin (define program (lambda ()
|
||||
(let ((y (call/cc (lambda (c) c))))
|
||||
(display 1)
|
||||
|
|
|
@ -1001,7 +1001,18 @@
|
|||
(error 'failure)))
|
||||
|
||||
|
||||
|
||||
(test '(begin (define K #f)
|
||||
(let ([x 3]
|
||||
[y 4]
|
||||
[z 5])
|
||||
(+ x y z (call/cc (lambda (r)
|
||||
(set! K r)
|
||||
0))))
|
||||
(let* ([a 0]
|
||||
[b 1])
|
||||
(+ 1024 (K 17))))
|
||||
29
|
||||
#:with-bootstrapping? #t)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user