Testing

;; "demo2.rkt"
(require test-engine/racket-tests)

(define (f x)
  (+ 3 (* 2 x)))

(module+ test
  (check-expect (f 0) 3)
  (check-expect (f -3/2) 0)
  ;; ordinarily bad style to have parens on lines by themselves
  )

(define (g x)
  (+ 3 (* x x)))

;; How would it matter if tests were not in the test submodule?

(module+ test
  (check-expect (g 5) 28))

(module+ test
  (test))

This will work in DrRacket as written. Another way: run raco test demo2.

Last modified October 17, 2024: Chapter 5 and Racket material added. (470022e)