Make tests have better names and remove duplicates.

This commit is contained in:
Eric Dobson 2013-12-01 23:00:56 -08:00
parent 0e8cf664f4
commit 775dd1509d
7 changed files with 23 additions and 32 deletions

View File

@ -56,10 +56,6 @@
[t-opt (() ()) (-> result)] [t-opt (() ()) (-> result)]
[t-opt ((one) ()) [t-opt ((one) ())
(-> one result)] (-> one result)]
[t-opt (() (one))
(cl->*
(-> one true result)
(-> false false result))]
[t-opt ((one two three four) ()) [t-opt ((one two three four) ())
(-> one two three four result)] (-> one two three four result)]
[t-opt (() (one)) [t-opt (() (one))

View File

@ -77,7 +77,6 @@
[(pred Number) (make-pred-ty N)] [(pred Number) (make-pred-ty N)]
[(-> (values Number Boolean Number)) (t:-> (-values (list N B N)))] [(-> (values Number Boolean Number)) (t:-> (-values (list N B N)))]
[(Number -> Number) (t:-> N N)] [(Number -> Number) (t:-> N N)]
[(Number -> Number) (t:-> N N)]
[(All (A) Number -> Number) (-poly (a) (t:-> N N))] [(All (A) Number -> Number) (-poly (a) (t:-> N N))]
[(All (A) (Number -> Number)) (-poly (a) (t:-> N N))] [(All (A) (Number -> Number)) (-poly (a) (t:-> N N))]
[(All (A) A -> A) (-poly (a) (t:-> a a))] [(All (A) A -> A) (-poly (a) (t:-> a a))]
@ -112,8 +111,6 @@
[(Listof Number) (make-Listof N)] [(Listof Number) (make-Listof N)]
[a (-v a) (dict-set initial-tvar-env 'a (-v a))] [a (-v a) (dict-set initial-tvar-env 'a (-v a))]
[(All (a ...) (a ... -> Number))
(-polydots (a) ((list) [a a] . ->... . N))]
[(Any -> Boolean : Number) (make-pred-ty -Number)] [(Any -> Boolean : Number) (make-pred-ty -Number)]
[(Any -> Boolean : #:+ (Number @ 0) #:- (! Number @ 0)) [(Any -> Boolean : #:+ (Number @ 0) #:- (! Number @ 0))

View File

@ -10,8 +10,8 @@
(define-syntax (over-tests stx) (define-syntax (over-tests stx)
(syntax-case stx () (syntax-case stx ()
[(_ [t1 t2 res] ...) [(_ [t1 t2 res] ...)
#'(test-suite "Tests for intersect" #'(test-suite "Tests for overlap"
(test-check (format "Overlap test: ~a ~a" 't1 't2) (lambda (a b) (eq? (not (not a)) b)) (overlap t1 t2) res) ...)])) (test-check (format "~a ~a" 't1 't2) (lambda (a b) (eq? (not (not a)) b)) (overlap t1 t2) res) ...)]))
(define overlap-tests (define overlap-tests
(over-tests (over-tests
@ -20,8 +20,8 @@
(define-syntax (restr-tests stx) (define-syntax (restr-tests stx)
(syntax-case stx () (syntax-case stx ()
[(_ [t1 t2 res] ...) [(_ [t1 t2 res] ...)
#'(test-suite "Tests for intersect" #'(test-suite "Tests for restrict"
(test-check (format "Restrict test: ~a ~a" 't1 't2) type-compare? (restrict t1 t2) res) ...)])) (test-check (format "~a ~a" 't1 't2) type-compare? (restrict t1 t2) res) ...)]))
(define restrict-tests (define restrict-tests
@ -50,7 +50,7 @@
[(_ [t1 t2 res] ...) [(_ [t1 t2 res] ...)
(syntax/loc stx (syntax/loc stx
(test-suite "Tests for remove" (test-suite "Tests for remove"
(test-check (format "Remove test: ~a ~a" 't1 't2) type-compare? (remove t1 t2) res) ...))])) (test-check (format "~a ~a" 't1 't2) type-compare? (remove t1 t2) res) ...))]))
(define remove-tests (define remove-tests
(remo-tests (remo-tests

View File

@ -31,7 +31,7 @@
(define-syntax (tc-e stx) (define-syntax (tc-e stx)
(syntax-parse stx (syntax-parse stx
[(_ expr ty) (syntax/loc stx (tc-e expr #:ret (ret ty)))] [(tc-e expr ty) (syntax/loc stx (tc-e expr #:ret (ret ty)))]
[(id a #:ret b) [(id a #:ret b)
(syntax/loc stx (syntax/loc stx
(test-case (format "~a ~a" (quote-line-number id) 'a) (test-case (format "~a ~a" (quote-line-number id) 'a)

View File

@ -8,10 +8,10 @@
(gen-test-main) (gen-test-main)
(define-syntax-rule (s img var tgt result) (define-syntax-rule (s img var tgt result)
(test-eq? "test" (substitute img 'var tgt) result)) (test-eq? (format "~a" '(img tgt)) (substitute img 'var tgt) result))
(define-syntax-rule (s... imgs var tgt result) (define-syntax-rule (s... imgs var tgt result)
(test-eq? "test" (substitute-dots (list . imgs) #f 'var tgt) result)) (test-eq? (format "~a" '(img tgt)) (substitute-dots (list . imgs) #f 'var tgt) result))
(define tests (define tests
(test-suite "Tests for substitution" (test-suite "Tests for substitution"

View File

@ -14,16 +14,13 @@
(define-syntax (te-tests stx) (define-syntax (te-tests stx)
(define (single-test stx) (define (single-test stx)
(syntax-case stx (FAIL) (syntax-case stx (FAIL)
[(FAIL t s) #'((test-check (format "FAIL ~a" '(t s)) (lambda (a b) (not (type-equal? a b))) t s) [(FAIL t s) (syntax/loc stx (test-check (format "FAIL ~a" '(t s))
(test-check (format "FAIL ~a" '(s t)) (lambda (a b) (not (type-equal? a b))) s t))] (lambda (a b) (not (type-equal? a b))) t s))]
[(t s) (syntax/loc stx [(t s) (syntax/loc stx (test-check (format "~a" '(t s)) type-equal? t s))]))
((test-check (format "~a" '(t s)) type-equal? t s)
(test-check (format "~a" '(s t)) type-equal? s t)))]))
(syntax-case stx () (syntax-case stx ()
[(_ cl ...) [(_ cl ...)
(with-syntax ([((cl1 cl2) ...) (map single-test (syntax->list #'(cl ...)))]) #`(test-suite "Tests for type equality"
#'(test-suite "Tests for type equality" #,@(map single-test (syntax->list #'(cl ...))))]))
cl1 ... cl2 ...))]))
(define (fld* t) (make-fld t (datum->syntax #'here 'values) #f)) (define (fld* t) (make-fld t (datum->syntax #'here 'values) #f))

View File

@ -56,6 +56,7 @@
(require (require
"evaluator.rkt" "evaluator.rkt"
"test-utils.rkt" "test-utils.rkt"
syntax/location
(for-syntax (for-syntax
racket/base racket/base
syntax/parse syntax/parse
@ -80,14 +81,14 @@
(pattern (~seq) #:attr v #'#f)) (pattern (~seq) #:attr v #'#f))
(define (check-no-error stx body) (define (test-no-error stx name body)
(quasisyntax/loc stx (quasisyntax/loc stx
(check-not-exn (test-not-exn (format "~a ~a" (quote-line-number #,name) '#,name)
(lambda () #,body)))) (lambda () #,body))))
(define (check-syntax-error stx body) (define (test-syntax-error stx name body)
(quasisyntax/loc stx (quasisyntax/loc stx
(check-exn (test-exn (format "~a ~a" (quote-line-number #,name) '#,name)
exn:fail:syntax? exn:fail:syntax?
(lambda () #,body))))) (lambda () #,body)))))
@ -96,10 +97,10 @@
(define-syntax (tc-e stx) (define-syntax (tc-e stx)
(syntax-parse stx (syntax-parse stx
[(_ code:expr #:proc p) [(_ code:expr #:proc p)
(check-no-error stx (test-no-error stx #'code
#'(phase1-eval (test/proc (quote-syntax code) p)))] #'(phase1-eval (test/proc (quote-syntax code) p)))]
[(_ code:expr return:return x:expected) [(_ code:expr return:return x:expected)
(check-no-error stx (test-no-error stx #'code
#'(phase1-eval (test (quote-syntax code) return.v x.v)))])) #'(phase1-eval (test (quote-syntax code) return.v x.v)))]))
(define-syntax (tc-e/t stx) (define-syntax (tc-e/t stx)
@ -110,7 +111,7 @@
(define-syntax (tc-l stx) (define-syntax (tc-l stx)
(syntax-parse stx (syntax-parse stx
[(_ lit ty exp:expected) [(_ lit ty exp:expected)
(check-no-error stx (test-no-error stx (syntax/loc #'lit (LITERAL lit))
#'(phase1-eval (test-literal #'lit ty exp.v)))])) #'(phase1-eval (test-literal #'lit ty exp.v)))]))
@ -118,13 +119,13 @@
(define-syntax (tc-err stx) (define-syntax (tc-err stx)
(syntax-parse stx (syntax-parse stx
[(_ code:expr ex:expected) [(_ code:expr ex:expected)
(check-syntax-error stx (test-syntax-error stx (syntax/loc #'code (FAIL code))
#'(phase1-eval (tc (tr-expand (quote-syntax code)) ex.v)))])) #'(phase1-eval (tc (tr-expand (quote-syntax code)) ex.v)))]))
(define-syntax (tc-l/err stx) (define-syntax (tc-l/err stx)
(syntax-parse stx (syntax-parse stx
[(_ lit:expr ex:expected) [(_ lit:expr ex:expected)
(check-syntax-error stx (test-syntax-error stx #'(syntax/loc #'lit (LITERAL/FAIL lit))
#'(phase1-eval (tc-literal #'lit ex.v)))])) #'(phase1-eval (tc-literal #'lit ex.v)))]))