typed-racket/typed-racket-test/unit-tests/test-utils.rkt
Andrew Kent 81b134cbb9 add refinement types, linear expr objs, and ineq props (#510)
This PR adds about half of the needed primitives and logic for
reasoning about linear integer arithmetic in programs with interesting
dependent types. Things have been added in a way s.t. programs will
still continue to typecheck as they did, but if you want integer literals
and certain operations (e.g. *,+,<,<=,=,>=,>) to include linear inequality
information by default, you need to include the
'#:with-linear-integer-arithmetic' keyword at the top of your module.

The other features needed to get TR to be able to check things like
verified vector operations will be to ajust function types so
dependencies can exist between arguments and a minor tweak to get
type inference to consider the symbolic objects of functions arguments.
These features should be coming shortly in a future pull request.
2017-03-27 14:32:29 -04:00

42 lines
1.1 KiB
Racket

#lang racket/base
(require racket/require-syntax
racket/match
racket/gui/dynamic
typed-racket/utils/utils
(for-syntax racket/base syntax/parse)
(types utils subtype)
(utils tc-utils)
(typecheck check-below)
(rep type-rep)
rackunit rackunit/text-ui)
(provide private typecheck (rename-out [infer r:infer])
utils env rep types base-env static-contracts
logic
(all-defined-out))
(define (tc-result-equal/test? res1 res2)
(define (below? res1 res2)
(parameterize ([delay-errors? #f])
(with-handlers ([exn:fail? (λ (_) #f)])
(check-below res1 res2)
#t)))
(and (below? res1 res2)
(below? res2 res1)))
(define-syntax (check-type-equal? stx)
(syntax-case stx ()
[(_ nm a b)
(syntax/loc stx (test-check nm type-equal? a b))]))
(define-syntax gen-test-main
(syntax-parser
[(stx:id)
#`(begin
(module* main #f
(require rackunit/text-ui)
(void (run-tests #,(datum->syntax #'stx 'tests))))
(module* test #f
(require (submod ".." main))))]))