[TIP] Model checking Python code
Ned Batchelder
ned at nedbatchelder.com
Sat Sep 5 08:34:13 PDT 2009
Matt Harrison wrote:
> On Sat, Sep 5, 2009 at 6:17 AM, Ned Batchelder<ned at nedbatchelder.com> wrote:
>
>> I'm still confused by the term "linear combinations of paths". What would a
>> non-linear combination of them be? Why don't people just say, "combinations
>> of paths"?
>>
>
> Check out McCabe's papers. At a minimum they are worth it for the
> mugshot at the end. Here's[0] the original, 33 years old now. It
> explains the theory. Here's a newer (a much longer) testing strategy
> one[1] thats only about 13 years old. It gives more examples.
>
> I'm actually re-working that talk now to give at a local open source
> conference.[2] Maybe I'll try and get the information out in a
> magazine article. Barring that I can put it on my blog.
>
> 0 - http://classes.cecs.ucf.edu/eel6883/berrios/notes/Paper%204%20(Complexity%20Measure).pdf
> 1 - http://www.mccabe.com/iq_research_nist.htm
> 2 - http://2009.utosc.com/presentation/92/
>
> --matt
>
>
While we're on the theory of the matter, I'm also a bit troubled by the
omission in these papers of exception throwing. Consider this C function:
int foo(int a)
{
return f1(a) + f2(a) + f3(a);
}
It has a cyclomatic complexity of 1. Now look at a similar function in
Python:
def foo(a):
return f1(a) + f2(a) + f3(a)
If any of f1, f2, or f3 can raise an exception (and in Python any one of
them can), then doesn't this have a complexity of 4? And if we're
trying to measure paths executed, we're a bit stuck, because it might be
that in fact f2 never raises an exception, so the "f2 raised" path will
never be executed, and that's not a fault in the test suite, it's a lack
of understanding of the system by the coverage tool.
--Ned.
--
Ned Batchelder, http://nedbatchelder.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/testing-in-python/attachments/20090905/75cf2dce/attachment.htm
More information about the testing-in-python
mailing list