| Back to TeachScheme! workshop | Back to Recipes |
Start with the simplest possible examples, then work up to more and more complicated examples. One way to write this is in a Scheme comment, e.g.
; Cube function: find the third power of a number ; cube: number => number ; (cube 0) => 0 ; (cube -3/5) => -27/125 ; (cube (cube 3)) => 19683
Another is to write it directly in the Definitions window, specifying the correct answers with "should be..." , but then insert the function definition in front of it, e.g.
; Cube function: find the third power of a number ; cube: number => number function definition will go here (cube 0) "should be 0" (cube -3/5) "should be -27/125" (cube (cube 3)) "should be 19683"
As of DrScheme version 203, there's a third way: you can create a test
suite with each of your test cases and its correct answers.
Initially, the suite will look like this:
After you've written the function definition and saved it, you can press
the "Execute" button on the test suite and the result should look like
this: