bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/6] examples: bistromathic: strengthen tests


From: Akim Demaille
Subject: [PATCH 2/6] examples: bistromathic: strengthen tests
Date: Sun, 1 Mar 2020 12:31:00 +0100

* examples/c/bistromathic/bistromathic.test: here.
* examples/test: Be clearer on failing tests.
---
 examples/c/bistromathic/bistromathic.test | 15 +++++++++++++--
 examples/c/bistromathic/parse.y           |  2 +-
 examples/c/bistromathic/scan.l            |  2 +-
 examples/test                             |  9 ++++++---
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/examples/c/bistromathic/bistromathic.test 
b/examples/c/bistromathic/bistromathic.test
index 116c7575..5ecff945 100755
--- a/examples/c/bistromathic/bistromathic.test
+++ b/examples/c/bistromathic/bistromathic.test
@@ -45,9 +45,20 @@ run 0 '0.16
 cat >input <<EOF
 *
 EOF
-run 0 "err: 1.1: syntax error: expected end of file or - or ( or end of line 
or double precision number or function or variable before *"
+run 0 'err: 1.1: syntax error: expected end of file or - or ( or end of line 
or double precision number or function or variable before *'
 
 cat >input <<EOF
 1 + 2 * * 3
 EOF
-run 0 "err: 1.9: syntax error: expected - or ( or double precision number or 
function or variable before *"
+run 0 'err: 1.9: syntax error: expected - or ( or double precision number or 
function or variable before *'
+
+cat >input <<EOF
+100%
+EOF
+run 0 '100
+err: 1.4: error: invalid character'
+
+cat >input <<EOF
+1 / 0
+EOF
+run 0 'err: 1.1-5: error: division by zero'
diff --git a/examples/c/bistromathic/parse.y b/examples/c/bistromathic/parse.y
index 9698161f..709651c2 100644
--- a/examples/c/bistromathic/parse.y
+++ b/examples/c/bistromathic/parse.y
@@ -123,7 +123,7 @@ exp:
   {
     if ($r == 0)
       {
-        yyerror (&@$, "division by zero");
+        yyerror (&@$, "error: division by zero");
         YYERROR;
       }
     else
diff --git a/examples/c/bistromathic/scan.l b/examples/c/bistromathic/scan.l
index e04cbc19..a0f60be5 100644
--- a/examples/c/bistromathic/scan.l
+++ b/examples/c/bistromathic/scan.l
@@ -62,6 +62,6 @@
 
 <<EOF>>  return TOK_EOF;
 
-.        yyerror (yylloc, "syntax error, invalid character");
+.        yyerror (yylloc, "error: invalid character");
 %%
 /* Epilogue (C code). */
diff --git a/examples/test b/examples/test
index 8fb8ec1e..50b5d8ce 100755
--- a/examples/test
+++ b/examples/test
@@ -90,9 +90,12 @@ run ()
       echo "$me: PASS: $number"
     else
       echo "$me: FAIL: $number"
-      echo "$me: expected output:  $out_exp"
-      echo "$me: effective output: $out_eff"
-      cat err_eff
+      echo "$me: input:"
+      sed -e 's/^/  /' input
+      echo "$me: expected output:"
+      echo "$out_exp" | sed -e 's/^/  /'
+      echo "$me: effective output:"
+      echo "$out_eff" | sed -e 's/^/  /'
       exit=false
     fi
   else
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]