tests: improve factoring of the main function

* tests/local.at (AT_MAIN_DEFINE): If %debug is used, check if
-d/--debug is passed to the generated parser, and enable the traces.
Return exactly the result of yyparse, so that we can check exit code
2 too.
* tests/actions.at, tests/glr-regression.at, tests/regression.at:
Use AT_MAIN_DEFINE, helping AT_BISON_OPTION_PUSHDEFS where needed,
preferably to option -t.
This commit is contained in:
Akim Demaille
2013-01-21 15:38:49 +01:00
parent 3ef9fa8f83
commit f42c012fcf
4 changed files with 61 additions and 117 deletions

View File

@@ -452,20 +452,32 @@ m4_define([AT_MAIN_DEFINE],
[m4_case(AT_LANG,
[c],
[[#include <stdlib.h> /* getenv. */
#include <string.h> /* strcmp. */
int
main (void)
{]AT_DEBUG_IF([
yydebug = !!getenv("YYDEBUG");])[
return !!yyparse ();
main (int argc, char const* argv[])
{]AT_DEBUG_IF([[
if (getenv("YYDEBUG")
|| (argc == 2
&& (!strcmp (argv[1], "-d") || !strcmp (argv[1], "--debug"))))
yydebug |= 1;]], [[
(void) argc;
(void) argv;]])[
return yyparse ();
}]],
[c++],
[[#include <cstdlib> // getenv.
#include <cstring> // strcmp.
int
main (void)
main (int argc, char const* argv[])
{
yy::parser p;]AT_DEBUG_IF([
p.set_debug_level (!!getenv("YYDEBUG"));])[
return !!p.parse ();
yy::parser p;]AT_DEBUG_IF([[
if (getenv("YYDEBUG")
|| (argc == 2
&& (!strcmp (argv[1], "-d") || !strcmp (argv[1], "--debug"))))
p.set_debug_level (true);]], [[
(void) argc;
(void) argv;]])[
return p.parse ();
}]],
[java],
[[class input