This preview shows page 1. Sign up to view the full content.
CS 135 Fall 2008 Byron Weber Becker, Ian Goldberg, Brad Lushman, Daniel Roche, Troy Vasiga Executable Examples This document describes a way of writing examples that can also be run as tests, to save you time in preparing your assignments. By no means is this required ; it is an optional alternative which you may choose to use. Recall that examples and tests serve two distinct purposes in the design recipe; see module 2 of your course notes and section 2.5 of the textbook for more details on the difference. For the simple function given below, the following shows the “traditional” way of using the design recipe. Notice that the examples are non-executable comments and the tests are all boolean tests which should evaluate to true . ;; dog-years: num → num ;; Converts an age in regular years to “dog years” ;; Examples: (dog-years 2) ⇒ 14 ( define ( dog-years hyears ) ( * 7 hyears )) ;; Tests for dog-years: ( = ( dog-years 2 ) 14 ) ( = ( dog-years 8 ) 56 ) ( = ( dog-years 0 ) 0 ) In the teaching languages, we can also write tests with the
This is the end of the preview. Sign up to access the rest of the document.
This note was uploaded on 10/21/2010 for the course CS 135 taught by Professor Vasiga during the Fall '07 term at Waterloo.
- Fall '07