add missing require, fix opt/c test suite
This commit is contained in:
parent
68f7e9f33b
commit
5b879d0680
|
@ -1,6 +1,7 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require "guts.rkt"
|
(require "guts.rkt"
|
||||||
|
"blame.rkt"
|
||||||
"opt.rkt"
|
"opt.rkt"
|
||||||
"base.rkt")
|
"base.rkt")
|
||||||
(require (for-syntax racket/base
|
(require (for-syntax racket/base
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
(module contract-opt-tests mzscheme
|
#lang racket/base
|
||||||
(require mzlib/contract
|
(require racket/contract
|
||||||
rackunit
|
rackunit
|
||||||
rackunit/text-ui)
|
rackunit/text-ui)
|
||||||
|
|
||||||
(define (exn:fail:contract-violation? exn)
|
(define (exn:fail:contract-violation? exn)
|
||||||
(if (regexp-match #rx"broke" (exn-message exn)) #t #f))
|
(if (regexp-match #rx"contract violation" (exn-message exn)) #t #f))
|
||||||
|
|
||||||
(define ((blame-to whom) exn)
|
(define ((blame-to whom) exn)
|
||||||
(and (exn:fail:contract-violation? exn)
|
(and (exn:fail:contract-violation? exn)
|
||||||
(regexp-match (format "~a broke" whom)
|
(regexp-match (regexp-quote (format "blaming ~a" whom))
|
||||||
(exn-message exn))))
|
(exn-message exn))))
|
||||||
|
|
||||||
(define ((match-msg msg) exn)
|
(define ((match-msg msg) exn)
|
||||||
|
@ -138,13 +138,13 @@
|
||||||
|
|
||||||
(test-exn
|
(test-exn
|
||||||
"between/c 2"
|
"between/c 2"
|
||||||
(match-msg "expected a number as first")
|
(match-msg "expected a real number as first")
|
||||||
(λ ()
|
(λ ()
|
||||||
(contract (opt/c (between/c 'x 'b)) 1 'pos 'neg)))
|
(contract (opt/c (between/c 'x 'b)) 1 'pos 'neg)))
|
||||||
|
|
||||||
(test-exn
|
(test-exn
|
||||||
"between/c 3"
|
"between/c 3"
|
||||||
(match-msg "expected a number as second")
|
(match-msg "expected a real number as second")
|
||||||
(λ ()
|
(λ ()
|
||||||
(contract (opt/c (between/c 1 'b)) 1 'pos 'neg)))
|
(contract (opt/c (between/c 1 'b)) 1 'pos 'neg)))
|
||||||
|
|
||||||
|
@ -277,8 +277,7 @@
|
||||||
(test-case
|
(test-case
|
||||||
"cons/c name 4"
|
"cons/c name 4"
|
||||||
(check-name '(cons/c (-> boolean? boolean?) integer?)
|
(check-name '(cons/c (-> boolean? boolean?) integer?)
|
||||||
(opt/c (cons/c (-> boolean? boolean?) integer?))))
|
(opt/c (cons/c (-> boolean? boolean?) integer?))))))
|
||||||
|
|
||||||
))
|
(unless (zero? (run-tests opt-tests))
|
||||||
|
(error 'contract-opt-tests.rkt "tests failed"))
|
||||||
(run-tests opt-tests))
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user