module scheme // Production builds remove assertions, including any evaluation inside them. // Keep evaluator setup and verification explicit in these gates. fn test_goops_production_method_factories_and_lexical_argument_locations() { mut vm := new() value := vm.eval('(define m (method* ((x ) #:optional (z 3) #:key (y 2)) (set! x (+ x 1)) (set! z (+ z 2)) (lambda () (next-method)))) (define bound ((slot-ref m (quote make-procedure)) (lambda args args))) (define first (bound 4)) (define second (bound 8 10 #:y 9)) (list (method-procedure m) (first) (second))') or { panic(err) } text := write(value) or { panic(err) } if text != '(#f (5 5) (9 12 #:y 9))' { panic('wrong escaped lexical-next bindings: ${text}') } vm.eval('(define saved #f) (define-method (g (x )) (* x 2)) (add-method! g (make #:specializers (list ) #:make-procedure (lambda (next) (let ((offset (call/cc (lambda (k) (set! saved k) 10)))) (lambda (x) (+ offset (next x)))))))') or { panic(err) } first := vm.eval('(g 4)') or { panic(err) } second := vm.eval('(saved 20)') or { panic(err) } third := vm.eval('(saved 30)') or { panic(err) } if first.whole() != 18 || second.whole() != 28 || third.whole() != 38 { panic('method factory continuation did not preserve the evaluator call') } }