Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Just to show some stuff that DrRacket inserts (when using htdp/bsl) and that is probably why some things were not working in emacs/geiser/repl.
#lang htdp/bsl
;; #reader(lib "" "lang")((modname area-tests) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
;; Given length of one side of square, produce the area of the square.
(check-expect (area-of-square 3) 3) ;; This test is wrong.
(check-expect (area-of-square 3.2) (* 3.2 3.2))
(define (area-of-square side)
(* side side))
;; When you test this, the first test will fail. The function is correct, but the
;; test is expecting that the area of a square with side 3 is 3, which is incorrect;
;; 9 would be the area of such a square.
;; If you change the function to conform to the test, you'll end up with a function
;; that produces incorrect values.

How to use htpd/bsl from emacs or command line

To run tests like those with check-expect, your .rkt file must start with:

#lang htdp/bsl


#reader(lib "" "lang")((modname area-tests) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))

But not both.

Then, from racket-mode, do C-c C-t (racket-test) and be happy. From the command line,

raco test file.rkt

Thanks to @lexi-lambda in #racket. He refused to change his nick to lexi-λ as I suggested, though.

Copy link

aaronhooper commented Apr 4, 2020

Thanks for this!

#lang syntax for HTDP seems to have no record on the Racket docs, so to include intermediate and advanced:

#lang htdp/bsl
#lang htdp/bsl+
#lang htdp/isl
#lang htdp/isl+
#lang htdp/asl

Copy link

FernandoBasso commented Apr 5, 2020

Thanks for the full list! Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment