"Strong typing vs. strong testing"

Pascal J. Bourguignon pjb at informatimago.com
Fri Oct 1 06:02:31 EDT 2010


Seebs <usenet-nospam at seebs.net> writes:

> On 2010-09-30, Ian Collins <ian-news at hotmail.com> wrote:
>> Which is why agile practices such as TDD have an edge.  If it compiles 
>> *and* passes all its tests, it must be right.
>
> So far as I know, that actually just means that the test suite is
> insufficient.  :)
>
> Based on my experience thus far, anyway, I am pretty sure it's essentially
> not what happens that the tests and code are both correct, and it is usually
> the case either that the tests fail or that there are not enough tests.

It also shows that for languages such as C, you cannot limit the unit tests
to the types declared for the function, but that you should try all the
possible values of the language.

Which basically, is the same as with dynamically typed programming
language, only now, some unit tests will fail early, when trying to
compile them while others will give wrong results later.


                                static              dynamic

compiler detects wrong type     fail at compile     fails at run-time
                                                    (with exception
                                                    explaining this is
                                                    the wrong type)

compiler passes wrong type      wrong result        fails at run-time
                                (the programmer     (with exception
                                spends hours        explaining this is
                                finding the         the wrong type)
                                problem)

compiler passes correct type    wrong result        wrong result
                                   (normal bug to be corrected)

compiler passes correct type    correct result      correct result



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/



More information about the Python-list mailing list