drracket icon indicating copy to clipboard operation
drracket copied to clipboard

`check-expect` snip output unfriendly

Open jasonhemann opened this issue 1 year ago • 10 comments

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.

jasonhemann avatar Jun 24 '24 19:06 jasonhemann

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.

rfindler avatar Jun 24 '24 23:06 rfindler

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?

mfelleisen avatar Jun 25 '24 01:06 mfelleisen

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.

sorawee avatar Jun 25 '24 06:06 sorawee

So

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

?

mfelleisen avatar Jun 25 '24 10:06 mfelleisen

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.

rfindler avatar Jun 25 '24 21:06 rfindler

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

jasonhemann avatar Jun 26 '24 01:06 jasonhemann

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

sorawee avatar Jun 30 '24 02:06 sorawee

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

mfelleisen avatar Jun 30 '24 03:06 mfelleisen

If I got it right, it looks like the framed thingy is an editor% snip here. https://github.com/racket/htdp/blob/8037f1cc620ed91fe68362ce5ad3d887269eb725/htdp-lib/test-engine/markup-gui.rkt#L145-L152 Is it possible for the copy behavior of the snip be changed to copying its content instead? (Or perhaps changing the pasting behavior. IIRC some snips do this.)

shhyou avatar Jul 03 '24 21:07 shhyou

Oh that's a great idea! (We would make a subclass and do that only for testing ones, I suppose.)

Robby

On Wed, Jul 3, 2024 at 4:15 PM shuhung @.***> wrote:

If I got it right, it looks like the framed thingy is an editor% snip here.

https://github.com/racket/htdp/blob/8037f1cc620ed91fe68362ce5ad3d887269eb725/htdp-lib/test-engine/markup-gui.rkt#L145-L152 Is it possible for the copy behavior of the snip be changed to copying its content instead?

— Reply to this email directly, view it on GitHub https://github.com/racket/drracket/issues/673#issuecomment-2207314334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBNMGGL52OQHYMJLHABJ3ZKRSYRAVCNFSM6AAAAABJ2M6PMWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBXGMYTIMZTGQ . You are receiving this because you commented.Message ID: @.***>

rfindler avatar Jul 03 '24 21:07 rfindler