racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
444 stars 93 forks source link

`check-expect` snip output unfriendly #673

Open jasonhemann opened 1 week ago

jasonhemann commented 1 week ago

The following error-scenario seems unnecessarily unfriendly, and I'm wondering if something nicer is possible.

A student might write the following test program:

#lang htdp/bsl
(require 2htdp/image)
(check-expect (circle 10 'outline 'black) 'o)

This test will fail. The student receives an error message containing a snip that contains the expected value. Our student then---mistakenly, accidentally, or what have you---then picks up the whole snip and drops that in as a replacement expect value.

Now that student sees the even more confusing:

Actual value . differs from (instantiate (class ...) ...), the expected value.

This seems especially injurious because it shows up when a student is already grappling with code that isn't behaving the way he expects. I for one do not know how to explain this behavior in a way that makes good sense to a BSL student. Is something nicer is possible?

I do not know if this properly belongs here, or in the htdp repo, or elsewhere.

rfindler commented 1 week ago

I'm not sure what's the best fix for this either, but one possibility might be an error saying that the box around the image snip is not a legal program in BSL. If that sounds right, then I think that that'd be a change in the bsl repo somewhere.

mfelleisen commented 1 week ago

I get

Welcome to DrRacket, version 8.13.0.9 [cs]. Language: htdp/bsl, with debugging [custom]. The test passed!

for

#lang htdp/bsl
(require 2htdp/image)
(check-expect (circle 10 'outline 'black) .)

when I copy over the black circle.

Why would a student copy-and-paste the square when he expects to see a black circle?

sorawee commented 1 week ago

Why would a student copy-and-paste the square when he expects to see a black circle?

Perhaps the student might not know that it is possible to copy only just the circle, and thought that the frame is just for decoration. I could see myself easily make this mistake.

mfelleisen commented 1 week ago

So

(if (image? x) x (frame (render x)))

?

rfindler commented 1 week ago

FWIW, I agree with Sorawee that what Jason describes is a totally reasonable (although wrong) thing to do and it would be good if something better happened in response to it. That said, I don't get what Matthias is trying to say with the if expression.

jasonhemann commented 6 days ago

I don't quite understand the suggested fix yet either.

sorawee commented 2 days ago

My guess is that Matthias was suggesting a workaround to make the framing snip comparable as an image?

mfelleisen commented 2 days ago

That's exactly what my if expression was supposed to suggest. [[ Sorry I was on the road for the week. ]]