Closed aymanosman closed 3 years ago
It looks like rackunit is explicitly turning values into strings via info-value->string
which isn't compatible with actually seeing certain values. For example, in this code, the first line prints "#(struct:object...." while the second shows the image.
#lang racket
(require 2htdp/image)
(displayln (~a (circle 50 "solid" "blue")))
(displayln (circle 50 "solid" "blue"))
picts need a bit more help; they have to be print
ed to show up. In this code, the first two show "#
#lang racket
(require pict)
(write (circle 50))
(display (format "~a" (circle 50)))
(print (circle 50))
(printf "~v" (circle 50))
It would be good if rackunit would print the values so that they'd show up in uses like this one, at least.
#lang racket
(require pict rackunit)
(check-equal? (circle 50) (circle 40))
which currently prints as:
Welcome to DrRacket, version 7.9.0.17--2020-12-24(dd1061f0/d) [cs].
Language: racket, with debugging; memory limit: 128 MB.
--------------------
. FAILURE
name: check-equal?
location: unsaved-editor:3:0
actual: #<pict>
expected: #<pict>
--------------------
Thanks for the pointers @rfindler.
It looks like it wouldn't be too difficult to support this use case. Here are the results of some quick hacking:
All I did was change the check-info-stack->string function to print-check-info-stack
and propogate those changes all the way.
It looks promising, if you'd be interested in a patch.
Problem
The "check-info stack" facility is unable to display visual data.
Motivation
While working on a graph algorithm, I found myself wanting to visualize the graphs I was computing.
rackunit
makes it convenient to associate extra information with a test case failure through the "check-info stack". I've always used that facility to associate textual data with my test cases, but now I found myself wanting to add visual data to that.Workaround
Since I can only display text in test failures, I simply included the dot representation of the graph, like so: