summaryrefslogtreecommitdiff
path: root/tests/diagnostics.at
diff options
context:
space:
mode:
Diffstat (limited to 'tests/diagnostics.at')
-rw-r--r--tests/diagnostics.at32
1 files changed, 28 insertions, 4 deletions
diff --git a/tests/diagnostics.at b/tests/diagnostics.at
index 15815db3..d9398dd5 100644
--- a/tests/diagnostics.at
+++ b/tests/diagnostics.at
@@ -35,17 +35,23 @@ AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]], [$2])
-AT_DATA([experr.orig], [$4])
+# For some reason, literal ^M in the input are removed and don't end
+# in `input.y`. So use the two-character ^M represent it, and let
+# Perl insert real CR characters.
+AT_CHECK([perl -pi -e 's{\^M}{\r}gx' input.y])
+
+AT_DATA([experr], [$4])
+
+AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
# When no style, same messages, but without style.
-AT_CHECK([perl -p -e 's{</?\w+>}{}g' <experr.orig >experr])
+AT_CHECK([perl -pi -e 's{(</?\w+>)}{ $[]1 eq "<tag>" ? $[]1 : "" }ge' experr])
+
# Cannot use AT_BISON_CHECK easily as we need to change the
# environment.
# FIXME: Enhance AT_BISON_CHECK.
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret -Wall input.y], [$3], [], [experr])
-AT_CHECK([cp experr.orig experr])
-AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
AT_BISON_OPTION_POPDEFS
@@ -255,6 +261,24 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
]])
+## ----------------- ##
+## Carriage return. ##
+## ----------------- ##
+
+# Carriage-return used to count as a newline in the scanner, and not
+# in diagnostics. Resulting in all sort of nice bugs.
+
+AT_TEST([[Carriage return]],
+[[^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M
+%token "
+%%
+]],
+[1],
+[[input.y:37.8-38.0: <error>error:</error> missing '"' at end of line
+input.y:37.8-38.0: <error>error:</error> syntax error, unexpected string, expecting char or identifier or <tag>
+]])
+
+
m4_popdef([AT_TEST])