Related articles |
---|
Testing strategy for compiler kuangpma@gmail.com (kuangpma) (2010-06-16) |
Re: Testing strategy for compiler gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-06-17) |
Re: Testing strategy for compiler zaimoni@zaimoni.com (Kenneth 'Bessarion' Boyd) (2010-06-17) |
Re: Testing strategy for compiler ott@mirix.org (Matthias-Christian Ott) (2010-06-18) |
Re: Testing strategy for compiler gene.ressler@gmail.com (Gene) (2010-06-18) |
Re: Testing strategy for compiler gneuner2@comcast.net (George Neuner) (2010-06-18) |
Re: Testing strategy for compiler gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-06-18) |
Re: Testing strategy for compiler ott@mirix.org (Matthias-Christian Ott) (2010-06-19) |
Re: Testing strategy for compiler gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-06-19) |
Re: Testing strategy for compiler jm@bourguet.org (Jean-Marc Bourguet) (2010-06-21) |
Re: Testing strategy for compiler dot@dotat.at (Tony Finch) (2010-06-21) |
Re: Testing strategy for compiler gneuner2@comcast.net (George Neuner) (2010-06-21) |
[8 later articles] |
From: | George Neuner <gneuner2@comcast.net> |
Newsgroups: | comp.compilers |
Date: | Fri, 18 Jun 2010 14:58:24 -0400 |
Organization: | A noiseless patient Spider |
References: | 10-06-037 10-06-044 |
Keywords: | testing, parse |
Posted-Date: | 19 Jun 2010 10:45:55 EDT |
On Fri, 18 Jun 2010 10:45:21 +0200, Matthias-Christian Ott
<ott@mirix.org> wrote:
>If you have a formal (generative) grammar for your language, you can
>generate all valid strings of language and test whether your parser
>recognises them. So you have practical tests which also cover obscure
>programmes. You could use yagg [1] for this purpose.
>
>[1] http://sourceforge.net/projects/yagg/
Our esteemed moderator wrote:
>[Any useful language has an infinite number of valid strings. I
>suppose you could generate enough to test that it can match each rule
>in the grammar. And this doesn't address the harder question of
>verifying that it'll reject invalid programs. -John]
You can generate enough that each language construct has every
possible use case covered. Many newbies forget to thoroughly test
recursive constructs and recursively applied algorithms. Somebody (I
forget who) said: "there are only three good numbers: 0, 1 and
infinity ... and sometimes 2".
But John is correct that this won't test semantics ... syntactically
correct programs can still be invalid. You need to make sure the
compiler rejects anything that is semantically wrong.
I once used a Pascal compiler that happily accepted garbage like
for n := 1 to 10 by -1
do ...
and generated an unreachable loop body. I forget why the optimizer
didn't just remove the loop ... probably the implementation used a
hidden loop counter to guarantee FOR iteration. What the compiler
should have done was reject the invalid step count.
George
Return to the
comp.compilers page.
Search the
comp.compilers archives again.