summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2020-12-04 06:49:26 -0500
committerEric S. Raymond <esr@thyrsus.com>2020-12-04 06:49:26 -0500
commit33bd31b74b23f5ba01046b3a492adb29acf75fc2 (patch)
tree79074a7db28548907c6e8d2b147fb61acf512de1
parent7b022d451d83a285b1bb41d5f41692ee2ef29b16 (diff)
downloadflex-git-33bd31b74b23f5ba01046b3a492adb29acf75fc2.tar.gz
Portability fix in tests - not all languages have ++ and --.
-rw-r--r--tests/lineno.rules4
-rw-r--r--tests/testmaker.m48
2 files changed, 10 insertions, 2 deletions
diff --git a/tests/lineno.rules b/tests/lineno.rules
index 7fc9c31..3cdfcaa 100644
--- a/tests/lineno.rules
+++ b/tests/lineno.rules
@@ -40,8 +40,8 @@ WORD [[:alpha:]]+
DIGIT [[:digit:]]
%%
-"yylineno++" ++yylineno;
-"yylineno--" --yylineno;
+"yylineno++" M4_TEST_INCREMENT(yylineno);
+"yylineno--" M4_TEST_DECREMENT(yylineno);
[[:blank:]]+
{WORD}
{DIGIT}+(\n{DIGIT}+)*
diff --git a/tests/testmaker.m4 b/tests/testmaker.m4
index 8af0964..08817ad 100644
--- a/tests/testmaker.m4
+++ b/tests/testmaker.m4
@@ -51,6 +51,8 @@ define(`M4_TEST_DO', `$1;')
define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);')
define(`M4_TEST_ASSERT', `if (!($1)) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}')
m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `flex_debug = 1;')')
+define(`M4_TEST_INCREMENT', `++$1')
+define(`M4_TEST_DECREMENT', `--$1')
define(`M4_TEST_POSTAMBLE', `dnl
int main (int argc, char **argv)
{
@@ -91,6 +93,8 @@ define(`M4_TEST_DO', `$1;')
define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);')
define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}')
m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `yyset_debug (yyget_debug(lexer), lexer);')')
+define(`M4_TEST_INCREMENT', `++$1')
+define(`M4_TEST_DECREMENT', `--$1')
define(`M4_TEST_POSTAMBLE', `dnl
int main (int argc, char **argv)
{
@@ -137,6 +141,8 @@ define(`M4_TEST_DO', `$1;')
define(`M4_TEST_FAILMESSAGE', `fprintf(stderr,"TEST FAILED: %d:\"%s\".\n", yylineno, yytext); exit(1);')
define(`M4_TEST_ASSERT', `if (!$1) {fprintf(stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); exit(1);}')
m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `yyset_debug (yyget_debug(lexer), lexer);')')
+define(`M4_TEST_INCREMENT', `++$1')
+define(`M4_TEST_DECREMENT', `--$1')
define(`M4_TEST_POSTAMBLE', `dnl
int main (int argc, char **argv)
{
@@ -173,6 +179,8 @@ define(`M4_TEST_DO', `$1')
define(`M4_TEST_FAILMESSAGE', `fmt.Fprintf(os.Stderr, "TEST FAILMESSAGE: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);')
define(`M4_TEST_ASSERT', `if !$1 {fmt.Fprintf(os.Stderr,"ASSERT FAILED: %d:\"%s\"\n", yylineno, yytext); os.Exit(1);}')
m4_ifdef(`M4_TEST_ENABLEDEBUG', `define(`M4_TEST_INITHOOK', `lexer.yysetDebug(lexer.yygetDebug())')')
+define(`M4_TEST_INCREMENT', `++$1')
+define(`M4_TEST_DECREMENT', `--$1')
define(`M4_TEST_POSTAMBLE', `dnl
func main(void) {
lexer := new(FlexLexer)