Fixing PR10950
This commit is contained in:
parent
3ff7b0461c
commit
2985001a79
|
@ -1,12 +1,21 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
(require racket/contract
|
||||||
(provide (all-defined-out))
|
"location.rkt"
|
||||||
|
(for-syntax racket/base
|
||||||
|
unstable/syntax))
|
||||||
|
|
||||||
;; Structures --------------------------------------------------
|
;; Structures --------------------------------------------------
|
||||||
|
|
||||||
;; struct check-info : symbol any
|
;; struct check-info : symbol any
|
||||||
(define-struct check-info (name value))
|
(define-struct check-info (name value))
|
||||||
|
|
||||||
|
(provide/contract
|
||||||
|
[struct check-info ([name symbol?]
|
||||||
|
[value any/c])]
|
||||||
|
[check-info-mark symbol?]
|
||||||
|
[check-info-stack (continuation-mark-set? . -> . (listof check-info?))]
|
||||||
|
[with-check-info* ((listof check-info?) (-> any) . -> . any)])
|
||||||
|
(provide with-check-info)
|
||||||
|
|
||||||
;; Infrastructure ----------------------------------------------
|
;; Infrastructure ----------------------------------------------
|
||||||
|
|
||||||
|
@ -33,32 +42,23 @@
|
||||||
(list (make-check-info name val) ...)
|
(list (make-check-info name val) ...)
|
||||||
(lambda () body ...))]))
|
(lambda () body ...))]))
|
||||||
|
|
||||||
(define (make-check-name name)
|
(define-syntax (define-check-type stx)
|
||||||
(make-check-info 'name name))
|
(syntax-case stx ()
|
||||||
(define (make-check-params params)
|
[(_ id contract)
|
||||||
(make-check-info 'params params))
|
(with-syntax
|
||||||
(define (make-check-location stx)
|
([make-check-id (format-id #'id "make-check-~a" #'id)]
|
||||||
(make-check-info 'location stx))
|
[check-id? (format-id #'id "check-~a?" #'id)])
|
||||||
(define (make-check-expression msg)
|
(syntax/loc stx
|
||||||
(make-check-info 'expression msg))
|
(begin (define (make-check-id a) (make-check-info 'id a))
|
||||||
(define (make-check-message msg)
|
(define (check-id? info) (eq? (check-info-name info) 'id))
|
||||||
(make-check-info 'message msg))
|
(provide/contract
|
||||||
(define (make-check-actual param)
|
[make-check-id (contract . -> . check-info?)]
|
||||||
(make-check-info 'actual param))
|
[check-id? (check-info? . -> . boolean?)]))))]))
|
||||||
(define (make-check-expected param)
|
|
||||||
(make-check-info 'expected param))
|
|
||||||
|
|
||||||
(define (check-name? info)
|
(define-check-type name any/c)
|
||||||
(eq? (check-info-name info) 'name))
|
(define-check-type params any/c)
|
||||||
(define (check-params? info)
|
(define-check-type location location/c)
|
||||||
(eq? (check-info-name info) 'params))
|
(define-check-type expression any/c)
|
||||||
(define (check-location? info)
|
(define-check-type message any/c)
|
||||||
(eq? (check-info-name info) 'location))
|
(define-check-type actual any/c)
|
||||||
(define (check-expression? info)
|
(define-check-type expected any/c)
|
||||||
(eq? (check-info-name info) 'expression))
|
|
||||||
(define (check-message? info)
|
|
||||||
(eq? (check-info-name info) 'message))
|
|
||||||
(define (check-actual? info)
|
|
||||||
(eq? (check-info-name info) 'actual))
|
|
||||||
(define (check-expected? info)
|
|
||||||
(eq? (check-info-name info) 'expected))
|
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
(syntax
|
(syntax
|
||||||
(lambda (formal ...
|
(lambda (formal ...
|
||||||
[message #f]
|
[message #f]
|
||||||
#:location [location 'unknown]
|
#:location [location (list 'unknown #f #f #f #f)]
|
||||||
#:expression [expression 'unknown])
|
#:expression [expression 'unknown])
|
||||||
((current-check-around)
|
((current-check-around)
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
(require racket/list
|
||||||
(require racket/list)
|
racket/contract)
|
||||||
|
|
||||||
(provide location-source
|
|
||||||
location-line
|
|
||||||
location-column
|
|
||||||
location-position
|
|
||||||
location-span
|
|
||||||
syntax->location
|
|
||||||
location->string)
|
|
||||||
|
|
||||||
;; type location = (list any number/#f number/#f number/#f number/#f)
|
;; type location = (list any number/#f number/#f number/#f number/#f)
|
||||||
;; location : source line column position span
|
;; location : source line column position span
|
||||||
|
(define location/c (list/c any/c (or/c number? false/c) (or/c number? false/c) (or/c number? false/c) (or/c number? false/c)))
|
||||||
|
|
||||||
(define location-source first)
|
(define location-source first)
|
||||||
(define location-line second)
|
(define location-line second)
|
||||||
|
@ -19,6 +12,16 @@
|
||||||
(define location-position fourth)
|
(define location-position fourth)
|
||||||
(define location-span fifth)
|
(define location-span fifth)
|
||||||
|
|
||||||
|
(provide/contract
|
||||||
|
[location/c contract?]
|
||||||
|
[location-source (location/c . -> . any/c)]
|
||||||
|
[location-line (location/c . -> . (or/c number? false/c))]
|
||||||
|
[location-column (location/c . -> . (or/c number? false/c))]
|
||||||
|
[location-position (location/c . -> . (or/c number? false/c))]
|
||||||
|
[location-span (location/c . -> . (or/c number? false/c))]
|
||||||
|
[syntax->location (syntax? . -> . location/c)]
|
||||||
|
[location->string (location/c . -> . string?)])
|
||||||
|
|
||||||
;; syntax->location : syntax -> location
|
;; syntax->location : syntax -> location
|
||||||
(define (syntax->location stx)
|
(define (syntax->location stx)
|
||||||
(list (syntax-source stx)
|
(list (syntax-source stx)
|
||||||
|
|
16
collects/tests/rackunit/pr10950.rkt
Normal file
16
collects/tests/rackunit/pr10950.rkt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#lang racket/base
|
||||||
|
(require rackunit
|
||||||
|
rackunit/text-ui
|
||||||
|
racket/port
|
||||||
|
tests/eli-tester)
|
||||||
|
|
||||||
|
(test
|
||||||
|
(with-output-to-string
|
||||||
|
(lambda ()
|
||||||
|
(parameterize ([current-error-port (current-output-port)])
|
||||||
|
(define-check (check3)
|
||||||
|
(fail-check))
|
||||||
|
|
||||||
|
(run-tests (test-suite "tests" (let ((foo check3)) (foo)))))))
|
||||||
|
=>
|
||||||
|
"--------------------\ntests > #f\nUnnamed test \nFAILURE\nname: check3\nlocation: unknown:?:?\nparams: \n--------------------\n0 success(es) 1 failure(s) 0 error(s) 1 test(s) run\n")
|
Loading…
Reference in New Issue
Block a user