[plt-scheme] HTDP: Testing programs

 From: Jos Koot (jos.koot at telefonica.net) Date: Wed Aug 27 16:51:47 EDT 2008 Previous message: [plt-scheme] HTDP: Testing programs Next message: [plt-scheme] HTDP: Testing programs Messages sorted by: [date] [thread] [subject] [author]

```----- Original Message -----
From: "Matthias Felleisen" <matthias at ccs.neu.edu>
To: "Shriram Krishnamurthi" <sk at cs.brown.edu>
Cc: "PLT List" <plt-scheme at list.cs.brown.edu>
Sent: Wednesday, August 27, 2008 3:18 PM
Subject: Re: [plt-scheme] HTDP: Testing programs

>
> Shriram's saying that the design recipe demands the creation of  examples
> *before* you create the function. The idea is that this  scales up to
> larger development efforts, too.
>
> In principle, a design looks like this:
>
> ;; f->c : Number -> Number
> ;; convert a fahrenheit temperature to a celsius temperature

Nitting a little bit I say that in most systems of dimensional units a
temperature is not a number. It is a number times a unit of temperature
relative to an offset temperature.
f -> c : Real Number -> Real Number
convert real number f to real number c such that f degrees Farhenheit = c
degrees Celcius,
where "=" is exact when f is exact and "=" is approximative when f is
inexact.

I say this because I am a little bit concerned about the many examples in
books about mathematics and programming that do not consistently apply the
theory of dimensions.
Imho it is wrong to say that the surface of a square with side 10 is 100.
This can only be correct in a system of units in which lengths have no
dimensional unit, but I never have seen such a system (on the contrary, the
*simplest* system of units I know of, has one dimensional unit, namely for
length)

This is important for progarammers too. We may *represent* a temperature by
a number with respect to a chosen scale of units but while programming we
should be aware of the fact that the representation is not the same as the
represented quantity.
Jos

>
> (check-expect (f->c 32) 0)
> (check-expect (f->c 212) 100)
>
> (define (f->c f-temp)
>  (cond
>    [(= f-temp 32) 0]
>    [(= f-temp 212) 100]
>    [else f-temp]))
>
> ;; ---
>
> Over the years, HtDP and drscheme have gotten a bit out of hand. One  day
> we'll catch up. -- Matthias
>
>
>
>
>
>
>
>
>
> On Aug 27, 2008, at 7:19 AM, Shriram Krishnamurthi wrote:
>
>> The intent is that you write test cases *before* you
>> test cases covered your program, DrScheme would
>> not complain at you.  Bad boy! (-:
>>
>> Shriram
>>
>> On Tue, Aug 26, 2008 at 11:39 PM, Grant Rettke <grettke at acm.org>  wrote:
>>> Hi folks,
>>>
>>> In HTDP beginner language on problem 2.2.1, when I evaluate it,
>>> DrScheme complains that "This program should be tested".
>>>
>>> is the intention that students start testing immediately, or we ill
>>>
>>> I used check-expect for now.
>>>
>>> Best wishes,
>>>
>>> Grant
>>> _________________________________________________
>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>
>> _________________________________________________