On this page:
check-ann
check-tc
check-not-tc
check-equal?-classes
check-equal?-classes:
28.1 Untyped versions of typed-rackunit-extensions
7.7

28 Extensions for typed/rackunit

Georges Dupéron <georges.duperon@gmail.com>

 (require phc-toolkit/typed-rackunit-extensions)
  package: phc-toolkit

syntax

(check-ann value type)

 
value = (ExpressionOf type)
     
type = Type
Verifies at compile-time that the given value is of the given type. The file will not compile if this check fails.

TODO: do the check at run-time, like check-tc.

syntax

(check-tc . body)

Verifies at run-time that the statments in body typecheck without any error.

TODO: fix possible problems with source location when the test fails.

syntax

(check-not-tc . body)

Verifies at run-time that the statments in body contain a type error. This can be used to check that the types provided by a library or generated by a macro are strong enough, by verifying that type errors that should be caught are caught.

TODO: fix possible problems with source location when the test fails.

procedure

(check-equal?-classes class ...)  Void

  class : ( (A) (Pairof String (Listof A)))
Verivies that the given elements form equality classes as indicated.

The car of each class indicates its name, and the rest is a list of element which belong to that class. All elements of the same class should have the same type Aᵢ, but elements of two different classes can have different types Aᵢ and Aⱼ.

This function checks that all elements of the same class are equal?, and that any two elements of two distinct classes are different. It also checks that elements are equal to themeselves, and checks equalities and inequalities in both directions, i.e. (and (equal? a b) (equal? b a)) for equalities, and (and (not (equal? a b)) (not (equal? b a))) for inequalities.

Be aware that this function has O(n{}^2) time complexity, with n being the total number of elements in all classes.

syntax

(check-equal?-classes: [maybe-nameᵢ maybe-typeᵢ elementᵢⱼ ...] ...)

 
maybe-nameᵢ = 
  | #:name String
     
maybe-typeᵢ = 
  | : tᵢ
     
tᵢ = Type
     
elementᵢⱼ = (ExpressionOf tᵢ or Any)
Macro form of check-equal?-classes. It is equivalent to (check-equal?-classes (list nameᵢ elementᵢ ...) ...), but also checks that each elementᵢⱼ is of the corresponding tᵢ type, if specified.

28.1 Untyped versions of typed-rackunit-extensions

 (require phc-toolkit/untyped/typed-rackunit-extensions)
  package: phc-toolkit