Adding check-member-of and check-range to the htdp languages and updating the docs.
svn: r16064
This commit is contained in:
parent
8cf13c8c0e
commit
e3c2721052
|
@ -55,6 +55,8 @@
|
||||||
check-expect
|
check-expect
|
||||||
check-within
|
check-within
|
||||||
check-error
|
check-error
|
||||||
|
check-member-of
|
||||||
|
check-range
|
||||||
#%datum
|
#%datum
|
||||||
#%top-interaction
|
#%top-interaction
|
||||||
empty true false)
|
empty true false)
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
check-expect
|
check-expect
|
||||||
check-within
|
check-within
|
||||||
check-error
|
check-error
|
||||||
|
check-member-of
|
||||||
|
check-range
|
||||||
#%datum
|
#%datum
|
||||||
#%top-interaction
|
#%top-interaction
|
||||||
empty true false)
|
empty true false)
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
check-expect
|
check-expect
|
||||||
check-within
|
check-within
|
||||||
check-error
|
check-error
|
||||||
|
check-member-of
|
||||||
|
check-range
|
||||||
#%datum
|
#%datum
|
||||||
#%top-interaction
|
#%top-interaction
|
||||||
empty true false)
|
empty true false)
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
check-expect
|
check-expect
|
||||||
check-within
|
check-within
|
||||||
check-error
|
check-error
|
||||||
|
check-member-of
|
||||||
|
check-range
|
||||||
#%datum
|
#%datum
|
||||||
#%top-interaction
|
#%top-interaction
|
||||||
empty true false)
|
empty true false)
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
check-expect
|
check-expect
|
||||||
check-within
|
check-within
|
||||||
check-error
|
check-error
|
||||||
|
check-member-of
|
||||||
|
check-range
|
||||||
#%datum
|
#%datum
|
||||||
#%top-interaction
|
#%top-interaction
|
||||||
empty true false)
|
empty true false)
|
||||||
|
|
|
@ -344,6 +344,8 @@ The same as Intermediate's @|intm-time|.}
|
||||||
@defform[(check-expect expr expr)]
|
@defform[(check-expect expr expr)]
|
||||||
@defform[(check-within expr expr expr)]
|
@defform[(check-within expr expr expr)]
|
||||||
@defform[(check-error expr expr)]
|
@defform[(check-error expr expr)]
|
||||||
|
@defform[(check-member-of expr expr)]
|
||||||
|
@defform[(check-range expr expr expr)]
|
||||||
)]{
|
)]{
|
||||||
|
|
||||||
The same as Beginning's @|beg-check-expect|, etc.}
|
The same as Beginning's @|beg-check-expect|, etc.}
|
||||||
|
|
|
@ -172,6 +172,8 @@ The same as Beginning's @|beg-and| and @|beg-or|.}
|
||||||
@defform[(check-expect expr expr)]
|
@defform[(check-expect expr expr)]
|
||||||
@defform[(check-within expr expr expr)]
|
@defform[(check-within expr expr expr)]
|
||||||
@defform[(check-error expr expr)]
|
@defform[(check-error expr expr)]
|
||||||
|
@defform[(check-member-of expr expr)]
|
||||||
|
@defform[(check-range expr expr expr)]
|
||||||
)]{
|
)]{
|
||||||
|
|
||||||
The same as Beginning's @|beg-check-expect|, etc.}
|
The same as Beginning's @|beg-check-expect|, etc.}
|
||||||
|
|
|
@ -243,6 +243,18 @@ A test case to check that the first @scheme[expr] signals an error,
|
||||||
where the error messages matches the string produced by the second
|
where the error messages matches the string produced by the second
|
||||||
@scheme[expr].}
|
@scheme[expr].}
|
||||||
|
|
||||||
|
@defform[(check-member-of expr expr)]{
|
||||||
|
|
||||||
|
A test case to check that the first @scheme[expr] produces an element
|
||||||
|
in the list of the second @scheme[expr].}
|
||||||
|
|
||||||
|
@defform[(check-range expr expr expr)]{
|
||||||
|
|
||||||
|
A test case to check that the first @scheme[expr] produces a number
|
||||||
|
inbetween the numbers produced by the second and third @scheme[expr]s,
|
||||||
|
inclusive.}
|
||||||
|
|
||||||
|
|
||||||
@; ----------------------------------------------------------------------
|
@; ----------------------------------------------------------------------
|
||||||
|
|
||||||
@section{@scheme[empty]}
|
@section{@scheme[empty]}
|
||||||
|
|
|
@ -178,6 +178,8 @@ The same as Intermediate's @|intm-time|.}
|
||||||
@defform[(check-expect expr expr)]
|
@defform[(check-expect expr expr)]
|
||||||
@defform[(check-within expr expr expr)]
|
@defform[(check-within expr expr expr)]
|
||||||
@defform[(check-error expr expr)]
|
@defform[(check-error expr expr)]
|
||||||
|
@defform[(check-member-of expr expr)]
|
||||||
|
@defform[(check-range expr expr expr)]
|
||||||
)]{
|
)]{
|
||||||
|
|
||||||
The same as Beginning's @|beg-check-expect|, etc.}
|
The same as Beginning's @|beg-check-expect|, etc.}
|
||||||
|
|
|
@ -217,6 +217,8 @@ The same as Beginning's @|beg-and| and @|beg-or|.}
|
||||||
@defform[(check-expect expr expr)]
|
@defform[(check-expect expr expr)]
|
||||||
@defform[(check-within expr expr expr)]
|
@defform[(check-within expr expr expr)]
|
||||||
@defform[(check-error expr expr)]
|
@defform[(check-error expr expr)]
|
||||||
|
@defform[(check-member-of expr expr)]
|
||||||
|
@defform[(check-range expr expr expr)]
|
||||||
)]{
|
)]{
|
||||||
|
|
||||||
The same as Beginning's @|beg-check-expect|, etc.}
|
The same as Beginning's @|beg-check-expect|, etc.}
|
||||||
|
|
|
@ -46,6 +46,19 @@ It is an error to produce a function value.}
|
||||||
Checks that evaluating the first expression signals an error, where
|
Checks that evaluating the first expression signals an error, where
|
||||||
the error message matches the string.}
|
the error message matches the string.}
|
||||||
|
|
||||||
|
@defform[(check-member-of (test any/c) (expecteds (listof any/c)))]{
|
||||||
|
|
||||||
|
Accepts two value-producing expressions, where the second expression
|
||||||
|
must evaluate to a list of values. Structurally compares the first
|
||||||
|
value to each value in the list.
|
||||||
|
|
||||||
|
It is an error to produce a function value.}
|
||||||
|
|
||||||
|
@defform[(check-range (test number/c) (min number/c) (max number/c))]{
|
||||||
|
|
||||||
|
Accepts three number-producing expressions. Performs the following comparison:
|
||||||
|
min <= test <= max.}
|
||||||
|
|
||||||
@defproc[(test) void?]{
|
@defproc[(test) void?]{
|
||||||
|
|
||||||
Runs all of the tests specified by check forms in the current module
|
Runs all of the tests specified by check forms in the current module
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;; The first three lines of this file were inserted by DrScheme. They record metadata
|
;; The first three lines of this file were inserted by DrScheme. They record metadata
|
||||||
;; about the language level of this file in a form that our tools can easily process.
|
;; about the language level of this file in a form that our tools can easily process.
|
||||||
#reader(lib "htdp-beginner-reader.ss" "lang")((modname TestEngineTest) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
|
#reader(lib "htdp-beginner-reader.ss" "lang")((modname TestEngineTest) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
|
||||||
;;Expect 29 checks, 17 failures
|
;;Expect 37 checks, 17 failures
|
||||||
|
|
||||||
(define (count f)
|
(define (count f)
|
||||||
(cond
|
(cond
|
||||||
|
@ -42,3 +42,16 @@
|
||||||
(check-error (/ 1 0) "/: division by zero")
|
(check-error (/ 1 0) "/: division by zero")
|
||||||
(check-error 3 "some message") ;fails
|
(check-error 3 "some message") ;fails
|
||||||
(check-error (first empty) "another message") ;fails
|
(check-error (first empty) "another message") ;fails
|
||||||
|
|
||||||
|
(check-member-of (make-ball 1 1 'blue) (list (make-ball 1 2 'blue) (make-ball 1 1 'blue) (make-ball 1 2 'red) 'red))
|
||||||
|
(check-member-of 1 (list 1 1 1 1))
|
||||||
|
(check-member-of (make-ball 2 2 'blue) (list (make-ball 1 2 'blue) (make-ball 1 1 'blue) (make-ball 1 2 'red) 'red)) ;fails
|
||||||
|
|
||||||
|
(check-range 5 0 10)
|
||||||
|
(check-range 0 0 10)
|
||||||
|
(check-range 10 0 10)
|
||||||
|
(check-range 11 0 10) ;fails
|
||||||
|
(check-range 5.01 0 10.5)
|
||||||
|
(check-range 0.0 0 10.5)
|
||||||
|
(check-range 10.5 0 10.5)
|
||||||
|
(check-range 10.5001 0 10.5) ;fails
|
||||||
|
|
Loading…
Reference in New Issue
Block a user