retabbing and dead code removal only

This commit is contained in:
John Clements 2011-07-09 13:33:59 -07:00
parent 3d03e8f884
commit ba82f46a07

View File

@ -4,362 +4,344 @@
"model-settings.rkt" "model-settings.rkt"
"shared.rkt") "shared.rkt")
(provide/contract [unwind (syntax? render-settings? . -> . syntax?)]) (provide/contract [unwind (syntax? render-settings? . -> . syntax?)])
; ;
; ;;; ;; ;;; ;;; ; ;; ;;; ; ; ; ;; ; ; ; ; ; ;; ;;; ; ; ; ;; ;; ; ; ;;; ;; ;;; ;;; ; ;; ;;; ; ; ; ;; ; ; ; ; ; ;; ;;; ; ; ; ;; ;; ;
;; ;; ; ; ; ; ;; ; ; ; ; ;; ; ; ; ; ; ;; ; ; ;; ; ;; ; ; ;; ;; ;; ; ; ; ; ;; ; ; ; ; ;; ; ; ; ; ; ;; ; ; ;; ; ;; ; ; ;;
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
; ; ; ;;;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ;; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ;;
; ; ; ;;;;; ;;; ; ;;; ;; ; ; ; ; ; ; ; ; ;;; ; ; ; ; ;; ; ; ; ; ;;;;; ;;; ; ;;; ;; ; ; ; ; ; ; ; ; ;;; ; ; ; ; ;; ;
; ;
; unwind takes a syntax object with a single highlight,
; and returns a list of syntax objects
(define (improper-member elt improper-list) ; unwind takes a syntax object with a single highlight,
(cond [(pair? improper-list) ; and returns a list of syntax objects
(or (eq? elt (car improper-list))
(improper-member elt (cdr improper-list)))]
[else
(eq? elt improper-list)]))
(define-syntax (noisy-and stx)
(syntax-case stx ()
[(_) #`#t]
[(_ a b ...)
(with-syntax ([inner (syntax/loc stx (noisy-and b ...))]
[error (syntax/loc #`a
(error 'noisy-and "and clause failed"))])
(syntax/loc stx (if a inner error)))]
[else
(error 'noisy-and "bad syntax for noisy-and")]))
;(->* (syntax? (listof syntax?)) (define (improper-member elt improper-list)
; (syntax? (listof syntax?))) (cond [(pair? improper-list)
(or (eq? elt (car improper-list))
(improper-member elt (cdr improper-list)))]
[else
(eq? elt improper-list)]))
(define (recur-on-pieces stx settings) ;(->* (syntax? (listof syntax?))
(if (pair? (syntax-e stx)) ; (syntax? (listof syntax?)))
(datum->syntax
stx (syntax-pair-map (syntax-e stx) (lambda (stx) (unwind stx settings))) stx stx)
stx))
(define (fall-through stx settings)
(kernel-syntax-case stx #f
[id
(identifier? stx)
(or (stepper-syntax-property stx 'stepper-lifted-name)
stx)]
[(define-values dc ...)
(unwind-define stx settings)]
; STC: app special cases from lazy racket
; extract-if-lazy-proc - can't hide this in lazy.rkt bc it's needed
; to distinguish the general lazy application
[(#%plain-app proc-extract p)
(or (eq? (syntax->datum #'proc-extract) 'extract-if-lazy-proc)
(eq? (object-name
(with-handlers ; for print output-style
([(λ (e) #t) (λ (e) #f)])
(syntax-e (second (syntax-e #'proc-extract)))))
'extract-if-lazy-proc))
(unwind #'p settings)]
; lazy #%app special case: force and delay
[(#%plain-app f arg)
(let ([fn (syntax->datum #'f)])
(or (eq? fn 'lazy-proc)
(eq? fn 'force) (eq? fn '!) (eq? fn '!!)
(eq? fn '!list) (eq? fn '!!list)
(equal? fn '(#%plain-app parameter-procedure))))
(unwind #'arg settings)]
; general lazy application
[(#%plain-app
(#%plain-lambda args1 (#%plain-app (#%plain-app proc p) . args2))
. args3)
(and (eq? (syntax->datum #'proc) 'extract-if-lazy-proc)
(equal? (syntax->datum (cdr (syntax-e #'args1)))
(syntax->datum #'args2)))
(recur-on-pieces #'args3 settings)]
[(#%plain-app exp ...)
(recur-on-pieces #'(exp ...) settings)]
[(quote datum)
(if (symbol? #'datum)
stx
#'datum)]
[(let-values . rest)
(unwind-mz-let stx settings)]
[(letrec-values . rest)
(unwind-mz-let stx settings)]
[(#%plain-lambda . rest)
(recur-on-pieces #'(lambda . rest) settings)]
[(set! var rhs)
(with-syntax ([unwound-var (or (stepper-syntax-property
#`var 'stepper-lifted-name)
#`var)]
[unwound-body (unwind #`rhs settings)])
#`(set! unwound-var unwound-body))]
[else (recur-on-pieces stx settings)]))
(define (unwind stx settings) (define (recur-on-pieces stx settings)
(transfer-info (if (pair? (syntax-e stx))
(let ([hint (stepper-syntax-property stx 'stepper-hint)]) (datum->syntax
(if (procedure? hint) stx (syntax-pair-map (syntax-e stx) (lambda (stx) (unwind stx settings))) stx stx)
; STC: For fn hints, I changed the recur procedure to unwind
; (was recur-on-pieces). This should not affect the non-lazy
; stepper since it doesnt seem to use any fn hints.
(hint stx (lambda (stx) (unwind stx settings)))
(let ([process (case hint
[(comes-from-cond) unwind-cond]
[(comes-from-and) (unwind-and/or 'and)]
[(comes-from-or) (unwind-and/or 'or)]
[(comes-from-local) unwind-local]
[(comes-from-recur) unwind-recur]
[(comes-from-check-expect) unwind-check-expect]
[(comes-from-check-within) unwind-check-within]
[(comes-from-check-error) unwind-check-error]
;;[(comes-from-begin) unwind-begin]
[else fall-through])])
(process stx settings))))
stx)) stx))
(define (transfer-highlight from to) (define (fall-through stx settings)
(if (stepper-syntax-property from 'stepper-highlight) (kernel-syntax-case stx #f
(stepper-syntax-property to 'stepper-highlight #t) [id
to)) (identifier? stx)
(or (stepper-syntax-property stx 'stepper-lifted-name)
(define (unwind-recur stx settings) stx)]
;; if you use #%app, it gets captured here [(define-values dc ...)
(with-syntax ([(app-keywd letrec-term argval ...) stx]) (unwind-define stx settings)]
(with-syntax ([(new-argval ...) ; STC: app special cases from lazy racket
(map (lambda (argval) (unwind argval settings)) (syntax->list #`(argval ...)))]) ; extract-if-lazy-proc - can't hide this in lazy.rkt bc it's needed
(let ([unwound (unwind #`letrec-term settings)]) ; to distinguish the general lazy application
(syntax-case unwound (letrec lambda) [(#%plain-app proc-extract p)
[(letrec ([loop-name (lambda (argname ...) . bodies)]) (or (eq? (syntax->datum #'proc-extract) 'extract-if-lazy-proc)
loop-name-2) (eq? (object-name
(unless (free-identifier=? #`loop-name #`loop-name-2) (with-handlers ; for print output-style
(error "unexpected syntax for 'recur': ~v" stx)) ([(λ (e) #t) (λ (e) #f)])
(transfer-highlight (syntax-e (second (syntax-e #'proc-extract)))))
unwound 'extract-if-lazy-proc))
#`(recur loop-name ([argname new-argval] ...) . bodies))] (unwind #'p settings)]
[else #`(#,unwound new-argval ...)]))))) ; lazy #%app special case: force and delay
[(#%plain-app f arg)
(define (unwind-define stx settings) (let ([fn (syntax->datum #'f)])
(kernel-syntax-case stx #f (or (eq? fn 'lazy-proc)
[(define-values (name . others) body) (eq? fn 'force) (eq? fn '!) (eq? fn '!!)
(if (null? (syntax-e #'others)) (eq? fn '!list) (eq? fn '!!list)
;; this is supported: (equal? fn '(#%plain-app parameter-procedure))))
(let* ([printed-name (unwind #'arg settings)]
(or (stepper-syntax-property #`name 'stepper-lifted-name) ; general lazy application
(stepper-syntax-property #'name 'stepper-orig-name) [(#%plain-app
#'name)] (#%plain-lambda args1 (#%plain-app (#%plain-app proc p) . args2))
[unwound-body (unwind #'body settings)] . args3)
;; see notes in internal-docs.txt (and (eq? (syntax->datum #'proc) 'extract-if-lazy-proc)
[define-type (stepper-syntax-property (equal? (syntax->datum (cdr (syntax-e #'args1)))
unwound-body 'stepper-define-type)]) (syntax->datum #'args2)))
(if define-type (recur-on-pieces #'args3 settings)]
(kernel-syntax-case [(#%plain-app exp ...)
unwound-body #f (recur-on-pieces #'(exp ...) settings)]
[(lambda arglist lam-body ...) [(quote datum)
(case define-type (if (symbol? #'datum)
[(shortened-proc-define) stx
(let ([proc-define-name #'datum)]
(stepper-syntax-property [(let-values . rest)
unwound-body (unwind-mz-let stx settings)]
'stepper-proc-define-name)]) [(letrec-values . rest)
(if (or (free-identifier=? proc-define-name (unwind-mz-let stx settings)]
#'name) [(#%plain-lambda . rest)
(and (stepper-syntax-property #'name (recur-on-pieces #'(lambda . rest) settings)]
'stepper-orig-name) [(set! var rhs)
(free-identifier=? (with-syntax ([unwound-var (or (stepper-syntax-property
proc-define-name #`var 'stepper-lifted-name)
(stepper-syntax-property #`var)]
#'name 'stepper-orig-name)))) [unwound-body (unwind #`rhs settings)])
#`(define (#,printed-name . arglist) #`(set! unwound-var unwound-body))]
lam-body ...) [else (recur-on-pieces stx settings)]))
#`(define #,printed-name
#,unwound-body)))] (define (unwind stx settings)
[(lambda-define) (transfer-info
#`(define #,printed-name #,unwound-body)] (let ([hint (stepper-syntax-property stx 'stepper-hint)])
[else (error 'unwind-define (if (procedure? hint)
"unknown value for syntax property 'stepper-define-type: ~e" ; STC: For fn hints, I changed the recur procedure to unwind
define-type)])] ; (was recur-on-pieces). This should not affect the non-lazy
; stepper since it doesnt seem to use any fn hints.
(hint stx (lambda (stx) (unwind stx settings)))
(let ([process (case hint
[(comes-from-cond) unwind-cond]
[(comes-from-and) (unwind-and/or 'and)]
[(comes-from-or) (unwind-and/or 'or)]
[(comes-from-local) unwind-local]
[(comes-from-recur) unwind-recur]
[(comes-from-check-expect) unwind-check-expect]
[(comes-from-check-within) unwind-check-within]
[(comes-from-check-error) unwind-check-error]
;; unused: the fake-exp begin takes care of this for us...
;;[(comes-from-begin) unwind-begin]
[else fall-through])])
(process stx settings))))
stx))
(define (transfer-highlight from to)
(if (stepper-syntax-property from 'stepper-highlight)
(stepper-syntax-property to 'stepper-highlight #t)
to))
(define (unwind-recur stx settings)
;; if you use #%app, it gets captured here
(with-syntax ([(app-keywd letrec-term argval ...) stx])
(with-syntax ([(new-argval ...)
(map (lambda (argval) (unwind argval settings)) (syntax->list #`(argval ...)))])
(let ([unwound (unwind #`letrec-term settings)])
(syntax-case unwound (letrec lambda)
[(letrec ([loop-name (lambda (argname ...) . bodies)])
loop-name-2)
(unless (free-identifier=? #`loop-name #`loop-name-2)
(error "unexpected syntax for 'recur': ~v" stx))
(transfer-highlight
unwound
#`(recur loop-name ([argname new-argval] ...) . bodies))]
[else #`(#,unwound new-argval ...)])))))
(define (unwind-define stx settings)
(kernel-syntax-case stx #f
[(define-values (name . others) body)
(if (null? (syntax-e #'others))
;; this is supported:
(let* ([printed-name
(or (stepper-syntax-property #`name 'stepper-lifted-name)
(stepper-syntax-property #'name 'stepper-orig-name)
#'name)]
[unwound-body (unwind #'body settings)]
;; see notes in internal-docs.txt
[define-type (stepper-syntax-property
unwound-body 'stepper-define-type)])
(if define-type
(kernel-syntax-case
unwound-body #f
[(lambda arglist lam-body ...)
(case define-type
[(shortened-proc-define)
(let ([proc-define-name
(stepper-syntax-property
unwound-body
'stepper-proc-define-name)])
(if (or (free-identifier=? proc-define-name
#'name)
(and (stepper-syntax-property #'name
'stepper-orig-name)
(free-identifier=?
proc-define-name
(stepper-syntax-property
#'name 'stepper-orig-name))))
#`(define (#,printed-name . arglist)
lam-body ...)
#`(define #,printed-name
#,unwound-body)))]
[(lambda-define)
#`(define #,printed-name #,unwound-body)]
[else (error 'unwind-define [else (error 'unwind-define
"expr with stepper-define-type is not a lambda: ~.s" "unknown value for syntax property 'stepper-define-type: ~e"
(syntax->datum unwound-body))]) define-type)])]
#`(define #,printed-name #,unwound-body))) [else (error 'unwind-define
;; this is there just to see the unsupported stuff go by... "expr with stepper-define-type is not a lambda: ~.s"
#`(define-values (name . others) #,(unwind #'body settings)) (syntax->datum unwound-body))])
)] #`(define #,printed-name #,unwound-body)))
[else (error 'unwind-define ;; this is there just to see the unsupported stuff go by...
"expression is not a define-values: ~.s" #`(define-values (name . others) #,(unwind #'body settings))
(syntax->datum stx))])) )]
[else (error 'unwind-define
(define (unwind-mz-let stx settings) "expression is not a define-values: ~.s"
(syntax-case stx () (syntax->datum stx))]))
[(label ([(var) rhs] ...) . bodies)
(with-syntax ([(rhs2 ...) (map (lambda (rhs) (unwind rhs settings)) (syntax->list #'(rhs ...)))] (define (unwind-mz-let stx settings)
[new-label (syntax-case stx ()
(if (improper-member 'comes-from-let* [(label ([(var) rhs] ...) . bodies)
(stepper-syntax-property (with-syntax ([(rhs2 ...) (map (lambda (rhs) (unwind rhs settings)) (syntax->list #'(rhs ...)))]
stx 'stepper-hint)) [new-label
#`let* (if (improper-member 'comes-from-let*
(case (syntax-e #'label) (stepper-syntax-property
[(let-values) #'let] stx 'stepper-hint))
[(letrec-values) #'letrec]))] #`let*
[new-bodies (map (lambda (body) (unwind body settings)) (syntax->list #'bodies))]) (case (syntax-e #'label)
;; is this let and the nested one part of a let*? [(let-values) #'let]
(syntax-case #`new-bodies (let*) [(letrec-values) #'letrec]))]
[((let* bindings inner-body ...)) [new-bodies (map (lambda (body) (unwind body settings)) (syntax->list #'bodies))])
(and ;; is this let and the nested one part of a let*?
(improper-member 'comes-from-let* (syntax-case #`new-bodies (let*)
(stepper-syntax-property stx 'stepper-hint)) [((let* bindings inner-body ...))
(same-source? stx (car (syntax->list #`new-bodies)))) (and
#`(let* #,(append (syntax->list #`([var rhs2] ...)) (improper-member 'comes-from-let*
(syntax->list #`bindings)) (stepper-syntax-property stx 'stepper-hint))
inner-body ...)] (same-source? stx (car (syntax->list #`new-bodies))))
[else #`(let* #,(append (syntax->list #`([var rhs2] ...))
#`(new-label ([var rhs2] ...) . new-bodies)]))] (syntax->list #`bindings))
[;; it's not part of the language we support... might as well just blow it on out there inner-body ...)]
(label ([(var ...) rhs] ...) . bodies) [else
(with-syntax ([(rhs2 ...) (map (lambda (rhs) (unwind rhs settings)) (syntax->list #'(rhs ...)))] #`(new-label ([var rhs2] ...) . new-bodies)]))]
[new-bodies (map (lambda (body) (unwind body settings)) (syntax->list #'bodies))]) [;; it's not part of the language we support... might as well just blow it on out there
#`(label ([(var ...) rhs2] ...) . new-bodies))])) (label ([(var ...) rhs] ...) . bodies)
(with-syntax ([(rhs2 ...) (map (lambda (rhs) (unwind rhs settings)) (syntax->list #'(rhs ...)))]
(define (unwind-local stx settings) [new-bodies (map (lambda (body) (unwind body settings)) (syntax->list #'bodies))])
(kernel-syntax-case stx #f #`(label ([(var ...) rhs2] ...) . new-bodies))]))
;; at least through intermediate, define-values may not occur in
;; local. (define (unwind-local stx settings)
[(letrec-values ([vars exp] ...) body) (kernel-syntax-case stx #f
(with-syntax ([defns (map (lambda (def) ;; at least through intermediate, define-values may not occur in
(unwind def settings)) ;; local.
(syntax->list [(letrec-values ([vars exp] ...) body)
#`((define-values vars exp) ...)))]) (with-syntax ([defns (map (lambda (def)
#`(local defns #,(unwind #'body settings)))] (unwind def settings))
[else (error 'unwind-local (syntax->list
"expected a letrec-values, given: ~.s" #`((define-values vars exp) ...)))])
(syntax->datum stx))])) #`(local defns #,(unwind #'body settings)))]
[else (error 'unwind-local
;(define (unwind-quasiquote-the-cons-application stx settings) "expected a letrec-values, given: ~.s"
; (syntax-case (recur-on-pieces stx settings) () (syntax->datum stx))]))
; [(#%app the-cons . rest)
; (syntax (cons . rest))] ;(define (unwind-quasiquote-the-cons-application stx settings)
; [else ; (syntax-case (recur-on-pieces stx settings) ()
; (error 'reconstruct ; [(#%app the-cons . rest)
; "unexpected result for unwinding the-cons application")])) ; (syntax (cons . rest))]
; [else
(define (unwind-cond-clause stx test-stx result-stx settings) ; (error 'reconstruct
(with-syntax ([new-test (if (stepper-syntax-property stx 'stepper-else) ; "unexpected result for unwinding the-cons application")]))
#`else
(unwind test-stx settings))] (define (unwind-cond-clause stx test-stx result-stx settings)
[result (unwind result-stx settings)]) (with-syntax ([new-test (if (stepper-syntax-property stx 'stepper-else)
#`(new-test result))) #`else
(unwind test-stx settings))]
(define (unwind-cond stx settings) [result (unwind result-stx settings)])
(let ([outer-stx stx]) #`(new-test result)))
(with-syntax
([clauses (define (unwind-cond stx settings)
(let loop ([stx stx]) (let ([outer-stx stx])
(if (and (same-source? outer-stx stx)) (with-syntax
(syntax-case stx (if begin let-values) ([clauses
;; the else clause disappears when it's a (let loop ([stx stx])
;; language-inserted else clause (if (and (same-source? outer-stx stx))
[(if test result) (syntax-case stx (if begin let-values)
(list (unwind-cond-clause stx #`test #`result settings))] ;; the else clause disappears when it's a
[(if test result else-clause) ;; language-inserted else clause
(cons (unwind-cond-clause stx #`test #`result settings) [(if test result)
(loop (syntax else-clause)))] (list (unwind-cond-clause stx #`test #`result settings))]
;; else clause appears momentarily in 'before,' even [(if test result else-clause)
;; though it's a 'skip-completely' (cons (unwind-cond-clause stx #`test #`result settings)
[(let-values () . rest) null] (loop (syntax else-clause)))]
[else-stx ;; else clause appears momentarily in 'before,' even
(error 'unwind-cond ;; though it's a 'skip-completely'
"expected an if, got: ~.s" [(let-values () . rest) null]
(syntax->datum (syntax else-stx)))]) [else-stx
(error 'unwind-cond (error 'unwind-cond
"expected a cond clause expansion, got: ~.s" "expected an if, got: ~.s"
(syntax->datum stx))))]) (syntax->datum (syntax else-stx)))])
(syntax (cond . clauses))))) (error 'unwind-cond
"expected a cond clause expansion, got: ~.s"
;; unused: the fake-exp begin takes care of this for us... (syntax->datum stx))))])
#;(define (unwind-begin stx settings) (syntax (cond . clauses)))))
(syntax-case stx (let-values)
[(let-values () body ...) (define ((unwind-and/or label) stx settings)
(with-syntax ([(new-body ...) (let ([user-source (syntax-property stx 'user-source)]
(map (lambda (body) (unwind body settings)) (syntax->list #`(body ...)))]) [user-position (syntax-property stx 'user-position)])
#`(begin new-body ...))])) (with-syntax
([clauses
(define ((unwind-and/or label) stx settings) (append
(let ([user-source (syntax-property stx 'user-source)] (if (render-settings-show-and/or-clauses-consumed? settings)
[user-position (syntax-property stx 'user-position)]) (build-list (stepper-syntax-property
(with-syntax stx 'stepper-and/or-clauses-consumed)
([clauses (let ([clause-padder
(append (if (render-settings-true-false-printed? settings)
(if (render-settings-show-and/or-clauses-consumed? settings) (case label [(and) #'true] [(or) #'false])
(build-list (stepper-syntax-property (case label [(and) #'#t] [(or) #'#f]))])
stx 'stepper-and/or-clauses-consumed) (lambda (dc) clause-padder)))
(let ([clause-padder '())
(if (render-settings-true-false-printed? settings) (let loop ([stx stx])
(case label [(and) #'true] [(or) #'false]) (if (and (eq? user-source
(case label [(and) #'#t] [(or) #'#f]))]) (syntax-property stx 'user-source))
(lambda (dc) clause-padder))) (eq? user-position
'()) (syntax-property stx 'user-position)))
(let loop ([stx stx]) (syntax-case stx (if)
(if (and (eq? user-source [(if part-1 part-2 part-3)
(syntax-property stx 'user-source)) (cons (unwind (syntax part-1) settings)
(eq? user-position (case label
(syntax-property stx 'user-position))) [(and) (loop (syntax part-2))]
(syntax-case stx (if) [(or) (loop (syntax part-3))]
[(if part-1 part-2 part-3) [else (error 'unwind-and/or
(cons (unwind (syntax part-1) settings) "unknown label ~a" label)]))]
(case label [else
[(and) (loop (syntax part-2))] (error 'unwind-and/or
[(or) (loop (syntax part-3))] "syntax: ~a does not match and/or patterns"
[else (error 'unwind-and/or (syntax->datum stx))])
"unknown label ~a" label)]))] null)))])
[else #`(#,label . clauses))))
(error 'unwind-and/or
"syntax: ~a does not match and/or patterns" (define (unwind-check-expect stx settings)
(syntax->datum stx))]) (kernel-syntax-case (fall-through stx settings) #f
null)))]) [(c-e (lambda () a1) a2 a3 a4)
#`(#,label . clauses)))) #`(check-expect a1 a2)]
[(dots1 actual dots2)
(define (unwind-check-expect stx settings) (and (eq? (syntax->datum #'dots1) '...)
(kernel-syntax-case (fall-through stx settings) #f (eq? (syntax->datum #'dots2) '...))
[(c-e (lambda () a1) a2 a3 a4) (with-syntax ([expected (unwind (third (stepper-syntax-property stx 'stepper-args-of-call)) settings)])
#`(check-expect a1 a2)] #`(check-expect actual expected))]
[(dots1 actual dots2) [any #`(c-e any) #;#`(check-expect )]))
(and (eq? (syntax->datum #'dots1) '...)
(eq? (syntax->datum #'dots2) '...)) (define (unwind-check-within stx settings)
(with-syntax ([expected (unwind (third (stepper-syntax-property stx 'stepper-args-of-call)) settings)]) (kernel-syntax-case (fall-through stx settings) #f
#`(check-expect actual expected))] [(c-e (lambda () a1) a2 a3 a4 a5)
[any #`(c-e any) #;#`(check-expect )])) #`(check-within a1 a2 a3)]
[(dots1 actual dots2)
(define (unwind-check-within stx settings) (and (eq? (syntax->datum #'dots1) '...)
(kernel-syntax-case (fall-through stx settings) #f (eq? (syntax->datum #'dots2) '...))
[(c-e (lambda () a1) a2 a3 a4 a5) (let ([args-of-call (stepper-syntax-property stx 'stepper-args-of-call)])
#`(check-within a1 a2 a3)] (with-syntax ([expected (unwind (third args-of-call) settings)]
[(dots1 actual dots2) [within (unwind (fourth args-of-call) settings)])
(and (eq? (syntax->datum #'dots1) '...)
(eq? (syntax->datum #'dots2) '...))
(let ([args-of-call (stepper-syntax-property stx 'stepper-args-of-call)])
(with-syntax ([expected (unwind (third args-of-call) settings)]
[within (unwind (fourth args-of-call) settings)])
#`(check-within actual expected within)))] #`(check-within actual expected within)))]
[any #`(c-e any) #;#`(check-expect )])) [any #`(c-e any) #;#`(check-expect )]))
(define (unwind-check-error stx settings) (define (unwind-check-error stx settings)
(kernel-syntax-case (fall-through stx settings) #f (kernel-syntax-case (fall-through stx settings) #f
[(c-e (lambda () a1) a2 a3 a4) [(c-e (lambda () a1) a2 a3 a4)
#`(check-error a1 a2)] #`(check-error a1 a2)]
[(dots1 actual dots2) [(dots1 actual dots2)
(and (eq? (syntax->datum #'dots1) '...) (and (eq? (syntax->datum #'dots1) '...)
(eq? (syntax->datum #'dots2) '...)) (eq? (syntax->datum #'dots2) '...))
(let ([args-of-call (stepper-syntax-property stx 'stepper-args-of-call)]) (let ([args-of-call (stepper-syntax-property stx 'stepper-args-of-call)])
(with-syntax ([expected (unwind (third args-of-call) settings)]) (with-syntax ([expected (unwind (third args-of-call) settings)])
#`(check-error actual expected)))] #`(check-error actual expected)))]
[any #`(c-e any) #;#`(check-expect )])) [any #`(c-e any) #;#`(check-expect )]))
(define (same-source? stx1 stx2) (define (same-source? stx1 stx2)
(and (equal? (syntax-property stx1 'user-source) (and (equal? (syntax-property stx1 'user-source)