X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fstep.impure.lisp;h=00aa7e091f8e636ed80086e6c90e0f8df0abe009;hb=2df8b5a0f18a3320d5b7652a958fae73cee1f937;hp=652ad2af3791991cab65657b55e225b7172f90f3;hpb=9943ee511c2e114876b2c6f52876984ad7087354;p=sbcl.git diff --git a/tests/step.impure.lisp b/tests/step.impure.lisp index 652ad2a..00aa7e0 100644 --- a/tests/step.impure.lisp +++ b/tests/step.impure.lisp @@ -26,17 +26,30 @@ (defvar *cerror-called* nil) +(define-condition cerror-break (error) ()) + (defun fib-break (x) (declare (optimize debug)) (if (< x 2) (progn (unless *cerror-called* - (cerror "a" "b") + (cerror "a" 'cerror-break) (setf *cerror-called* t)) 1) (+ (fib-break (1- x)) (fib-break (- x 2))))) +(defun in () + (declare (optimize debug)) + (print 1) + (print 2) + (print 3) + (print 4)) + +(defun out () + (declare (optimize debug)) + (in)) + (defun test-step-into () (let* ((results nil) (expected '(("(< X 2)" :unknown) @@ -133,7 +146,7 @@ results) (invoke-restart 'step-into)))))) (setf *cerror-called* nil) - (handler-bind ((error + (handler-bind ((cerror-break (lambda (c) (sb-impl::enable-stepping) (invoke-restart 'continue)))) @@ -162,32 +175,73 @@ (backtrace))))))) (step (fib 3)))) +(defun test-step-next/2 () + (let* ((results nil) + (expected '(("(IN)" ()) + ("(PRINT 1)" (1)) + ("(PRINT 2)" (2)) + ("(PRINT 3)" (3)) + ("(PRINT 4)" (4)))) + (count 0) + (*stepper-hook* (lambda (condition) + (typecase condition + (step-form-condition + (push (list (step-condition-form condition) + (step-condition-args condition)) + results) + (if (>= (incf count) 3) + (invoke-restart 'step-into) + (invoke-restart 'step-into))))))) + (step (out)) + (assert (equal expected (reverse results))))) + +(defun test-step-out/2 () + (let* ((results nil) + (expected '(("(IN)" ()) + ("(PRINT 1)" (1)) + ("(PRINT 2)" (2)))) + (count 0) + (*stepper-hook* (lambda (condition) + (typecase condition + (step-form-condition + (push (list (step-condition-form condition) + (step-condition-args condition)) + results) + (if (>= (incf count) 3) + (invoke-restart 'step-out) + (invoke-restart 'step-into))))))) + (step (out)) + (assert (equal expected (reverse results))))) + (with-test (:name :step-into) - (handler-bind ((step-condition (lambda (c) - (funcall *stepper-hook* c)))) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) (test-step-into))) (with-test (:name :step-next) - (handler-bind ((step-condition (lambda (c) - (funcall *stepper-hook* c)))) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) (test-step-next))) (with-test (:name :step-out) - (handler-bind ((step-condition (lambda (c) - (funcall *stepper-hook* c)))) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) (test-step-out))) (with-test (:name :step-start-from-break) - (handler-bind ((step-condition (lambda (c) - (funcall *stepper-hook* c)))) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) (test-step-start-from-break))) (with-test (:name :step-frame) - (handler-bind ((step-condition (lambda (c) - (funcall *stepper-hook* c)))) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) (test-step-frame))) (with-test (:name :step-backtrace) - (handler-bind ((step-condition (lambda (c) - (funcall *stepper-hook* c)))) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) (test-step-backtrace))) + +(with-test (:name :step-next/2) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) + (test-step-next/2))) + +(with-test (:name :step-out/2) + (handler-bind ((step-condition #'sb-impl::invoke-stepper)) + (test-step-out/2))) +