borisdiakur
borisdiakur

Reputation: 12072

How to print racket check-expect results in terminal

I have the following racket code:

(require test-engine/racket-tests)

(define (square val)
  (* val val))

(check-expect (square 3) 9)

When I execute the script in DrRacket using the Beginning Student language, I get the following output in the application console (the view is called “Interactions” in DrRacket):

The test passed!

When I execute the same script in the Terminal via racket my_script.rkt I do not see any output. I checked racket --help but I don’t see any viable option. How can I execute the script in the Terminal and have the same line printed out?

Upvotes: 1

Views: 922

Answers (1)

uselpa
uselpa

Reputation: 18917

The following works for me in both DrRacket and in the terminal:

#lang racket/base
(require test-engine/racket-tests)

(define (square val)
  (* val val))

(check-expect (square 3) 9)
(test)

and prints

The only test passed!

Note that had to add (test) to make this happen, both in DrRacket and on the command line, according to this doc.

Upvotes: 5

Related Questions