Test cases and static typing
Pascal Costanza
costanza at web.de
Fri Oct 24 13:56:22 EDT 2003
Dirk Thierbach wrote:
> Pascal Costanza <costanza at web.de> wrote:
>
>>Dirk Thierbach wrote:
>
>>OK, I have got it. No, that's not what I want. What I want is:
>>
>>testxyz obj = (concretemethod obj == 42)
>>
>>Does the code compile as long as concretemethod doesn't exist?
>
> No. Does your test pass as long as conretemthod doesn't exist? It doesn't,
> for the same reason.
As long as I am writing only tests, I don't care. When I am in the mood
of writing tests, I want to write as many tests as possible, without
having to think about whether my code is acceptable for the static type
checker or not.
>>>It's the same with compile-time type errors. The only difference is
>>>that they happen at compile-time, not at test-suite run-time, but the
>>>necessary reaction is the same: Fix your code so that all tests (or
>>>the compiler-generated type "tests") pass. Then continue with the next
>>>step.
>
>>The type system might test too many cases.
>
> I have never experienced that, because every expression that is valid
> code will have a proper type.
>
> Can you think of an example (not in C++ or Java etc.) where the type
> system may check too many cases?
Here is one:
(defun f (x)
(unless (< x 200)
(cerror "Type another number"
"You have typed a wrong number")
(f (read)))
(* x 2))
Look up
http://www.lispworks.com/reference/HyperSpec/Body/f_cerror.htm#cerror
before complaining.
Pascal
--
Pascal Costanza University of Bonn
mailto:costanza at web.de Institute of Computer Science III
http://www.pascalcostanza.de Römerstr. 164, D-53117 Bonn (Germany)
More information about the Python-list
mailing list