News

Wrong assertion in "Metamorphic Testing" lab that, however, reveals an actual bug in tested function

Written on 05.07.2023 10:20 by Dominic Steinhöfel

Dear seminar participants,

Justin (thanks!) pointed out that the final assertion/check in the "Metamorphic Testing" lab is wrong; it does not call the function `test_tiny_c_interpreter_with_wrong_dict`, but the original `test_tiny_c_interpreter`. Please correct these yourselves.

However, I found a bug at this second call to `test_tiny_c_interpreter`, which is why I missed that problem. The root cause of this bug is the ambiguity of the Tiny-C grammar. For example, the program

{a = 17;if(0) if(1) ; else a = 42;}

has two parses: One equivalent to

{a = 17;if(0) {if(1) ; else a = 42;}}

which is the intended one, and one equivalent to

{a = 17;if(0) {if(1) ;} else a = 42;}

which is the first result returned by the EarleyParser. This latter alternative is not "dead code" and can alter the semantics.

This is an excellent lesson on language ambiguity and the problems one may face when dealing with "grammarware." To solve this, we could resolve the ambiguity in the grammar, replace the grammar-based parser altogether, or adapt the grammar to work with ISLa's "packrat parser." This parser is currently not used since, for the current grammar, packrat runs into an infinite recursion problem.

Long story short:

  1. Please change the mentioned function call, and don't be surprised if the original call occasionally also finds an error :)
  2. The test routines we're building here, even these simple ones, WORK!
  3. Thanks, Justin! For the others: Keep reporting suspicious stuff ;)

Best,
Dominic

Privacy Policy | Legal Notice
If you encounter technical problems, please contact the administrators.