[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/13] java: tests: check push parsers
From: |
Akim Demaille |
Subject: |
[PATCH 12/13] java: tests: check push parsers |
Date: |
Wed, 5 Feb 2020 18:05:04 +0100 |
Currently in javapush.at.
* tests/calc.at: Here.
---
tests/calc.at | 26 +++++++++++++++++++++-----
tests/javapush.at | 5 +++++
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/tests/calc.at b/tests/calc.at
index 96ba5c54..f2f40fd8 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -726,8 +726,8 @@ m4_define([AT_DATA_CALC_Y],
# count them.
m4_define([_AT_CHECK_CALC],
[AT_DATA([[input]],
-[[$2
-]])
+[$2
+])
AT_JAVA_IF(
[AT_JAVA_PARSER_CHECK([Calc < input], 0, [AT_PARAM_IF([m4_n([$3])])],
[stderr])],
[AT_PARSER_CHECK([calc input], 0, [AT_PARAM_IF([m4_n([$3])])],
[stderr])])
@@ -843,6 +843,15 @@ m4_define([AT_CHECK_SPACES],
])
+# AT_CHECK_JAVA_GREP(FILE, [LINE], [COUNT=1])
+# -------------------------------------------
+# Check that FILE contains exactly COUNT lines matching ^LINE$
+# with grep. Unquoted so that COUNT can be a shell expression.
+m4_define([AT_CHECK_JAVA_GREP],
+[AT_CHECK_UNQUOTED([grep -c '^$2$' $1], [ignore], [m4_default([$3], [1])
+])])
+
+
# AT_CHECK_CALC([BISON-OPTIONS], [COMPILER-OPTIONS])
# --------------------------------------------------
# Start a testing chunk which compiles 'calc' grammar with
@@ -857,13 +866,18 @@ AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE(AT_JAVA_IF([[Calc]], [[calc]]), AT_DEFINES_IF([[lex], [main]],
[[], []]), [$2], [-Wno-deprecated])
+AT_PUSH_IF([AT_JAVA_IF(
+ [# Verify that this is a push parser.
+ AT_CHECK_JAVA_GREP([[Calc.java]],
+ [[.*public void push_parse_initialize ().*]])])])
+
AT_CHECK_SPACES([AT_JAVA_IF([Calc], [calc]).AT_LANG_EXT
AT_DEFINES_IF([AT_JAVA_IF([Calc], [calc]).AT_LANG_HDR])])
# Test the precedences.
# The Java traces do not show the clean up sequence at the end,
# since it does not support %destructor.
_AT_CHECK_CALC([$1],
-[1 + 2 * 3 = 7
+[[1 + 2 * 3 = 7
1 + 2 * -3 = -5
-1^2 = -1
@@ -875,7 +889,7 @@ _AT_CHECK_CALC([$1],
1 - (2 - 3) = 2
2^2^3 = 256
-(2^2)^3 = 64],
+(2^2)^3 = 64]],
[[final: 64 12 0]],
[AT_JAVA_IF([1014], [1017])])
@@ -1161,9 +1175,11 @@ m4_define([AT_CHECK_CALC_LALR1_JAVA],
AT_CHECK_CALC_LALR1_JAVA
AT_CHECK_CALC_LALR1_JAVA([%define parse.error verbose])
AT_CHECK_CALC_LALR1_JAVA([%locations %define parse.error verbose])
-AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose
%locations])
+AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose])
AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose
%locations %lex-param {InputStream is}])
+AT_CHECK_CALC_LALR1_JAVA([%define api.push-pull both])
+AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose
%locations %lex-param {InputStream is} %define api.push-pull both])
m4_popdef([AT_TOKEN_TRANSLATE_IF])
m4_popdef([AT_CALC_MAIN])
diff --git a/tests/javapush.at b/tests/javapush.at
index 2737048c..940a8886 100644
--- a/tests/javapush.at
+++ b/tests/javapush.at
@@ -236,6 +236,11 @@ AT_CHECK_JAVA_GREP(
[1])
AT_CLEANUP
+
+## ------------------------------ ##
+## Calculator with a push parser ##
+## ------------------------------ ##
+
# Define a single copy of the Calculator grammar.
m4_define([AT_CALC_BODY],[
%code imports {
--
2.25.0
- [PATCH 01/13] traces: write the "Reading a token" alone on its line, (continued)
- [PATCH 01/13] traces: write the "Reading a token" alone on its line, Akim Demaille, 2020/02/05
- [PATCH 02/13] traces: show the stack after reading a token, Akim Demaille, 2020/02/05
- [PATCH 05/13] java: examples: prefer switch to chains of else-if, Akim Demaille, 2020/02/05
- [PATCH 04/13] java: examples: split in two, Akim Demaille, 2020/02/05
- [PATCH 06/13] java: examples: fix the tracking of locations, Akim Demaille, 2020/02/05
- [PATCH 07/13] java: style: prefer putting the square brackets on the type, Akim Demaille, 2020/02/05
- [PATCH 08/13] java: style: avoid useless initializers, Akim Demaille, 2020/02/05
- [PATCH 09/13] java: tests: prepare the replacement of calculator tests, Akim Demaille, 2020/02/05
- [PATCH 10/13] java: tests: check location tracking in the calculator, Akim Demaille, 2020/02/05
- [PATCH 12/13] java: tests: check push parsers,
Akim Demaille <=
- [PATCH 11/13] java: tests: remove now redundant tests, Akim Demaille, 2020/02/05
- [PATCH 13/13] java: tests: remove now redundant tests, Akim Demaille, 2020/02/05