[plt-scheme] ProfessorJ, ==, and double
Quoth Carl Eastlund:
> If either way has to be given with a caveat, there's at least
> something to be said for choosing the simpler of the two incomplete
> solutions. I'm with you that epsilon-testing is probably better, but
> "==" gives them something to write in the first week or two.
...except that what they write won't actually work, sometimes, in a way
that will be completely mysterious.
> > But where are you actually using == ? Test cases don't require them.
>
> Test cases don't test anything unless they compare to an expected
> value, and putting "should be about 3.33" in a comment doesn't force
> the students to actually perform the comparison. So we try to get
> them to produce booleans in code as often as possible, which requires
> comparing results (often doubles) to something or other.
Ah, of course you want more than just comments. From the Special menu,
select "Insert Test Case"; you can then type arbitrary expressions in
the "To test" and "Expected" box, and ProfJ will compare them for you.
It uses == for all numeric types (including, unfortunately, double),
equals for Strings, and some complicated thing for user-defined classes
that does about what you'd want it to even if equals is not (re)defined.
I can now see where if test cases weren't available you'd feel more
pressed to use ==, though.
--
-=-Don Blaheta-=-dblaheta at knox.edu-=-=-<http://faculty.knox.edu/dblaheta/>-=-
"Dr Thurley said the left arm of the skeleton was folded across the
chest, suggesting a Christian burial. But the ornate scallop shell
decoration on the outside of the lead coffin had been thought to be
pagan symbols, a sign of what he called "an interesting insurance
policy"." --BBC