Add tests for check-below.

original commit: d2c415f5979caf4d93248ee0a9b6a6a2b7ee4736
This commit is contained in:
Eric Dobson 2014-02-28 19:26:12 -08:00
commit f2e2a4b7f9
2 changed files with 51 additions and 0 deletions

View File

@ -35,4 +35,5 @@
"interactive-tests.rkt"
"class-tests.rkt"
"class-util-tests.rkt"
"check-below-tests.rkt"
"rep-tests.rkt")

View File

@ -0,0 +1,50 @@
#lang racket/base
(require "test-utils.rkt"
rackunit
(types abbrev union tc-result)
(rep filter-rep)
(typecheck check-below)
(for-syntax racket/base syntax/parse))
(provide tests)
(gen-test-main)
(define-syntax test-below
(syntax-parser
[(_ t1:expr t2:expr)
#'(check-not-exn (lambda () (check-below t1 t2)))]
[(_ #:fail (~optional message:expr #:defaults [(message #'#rx"type mismatch")]) t1:expr t2:expr)
#'(check-exn message
(lambda () (check-below t1 t2)))]))
(define tests
(test-suite "Check Below"
(test-below (Un) Univ)
(test-below #:fail -Symbol -String)
(test-below
(ret (list -Symbol) (list -no-filter) (list -no-obj))
(ret (list Univ) (list -no-filter) (list -no-obj)))
(test-below #:fail
(ret (list -Symbol) (list -top-filter) (list -no-obj))
(ret (list Univ) (list -true-filter) (list -no-obj)))
;; Enable these once check-below is fixed
#;
(test-below #:fail
(ret (list Univ) (list -no-filter) (list -no-obj) Univ 'B)
(ret (list Univ) (list -false-filter) (list -no-obj) Univ 'B))
#;
(test-below #:fail
(ret (list Univ) (list -no-filter) (list -no-obj))
(ret (list Univ) (list -false-filter) (list -no-obj) Univ 'B))
#;
(test-below #:fail
(ret (list Univ Univ) (list -no-filter -no-filter) (list -no-obj -no-obj))
(ret (list Univ Univ) (list -false-filter -false-filter) (list -no-obj -no-obj)))
))