tests: java: avoid recent Java features

Tests 463 and 464 fail with Java 1.4 compilers.

Reported by Michael Felt.
<http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00091.html>

* tests/javapush.at: Use StringBuffer instead of StringBuilder.
This commit is contained in:
Akim Demaille
2015-02-10 14:56:01 +01:00
parent 9524161147
commit 3d75e7de1e

View File

@@ -241,10 +241,13 @@ m4_define([AT_CALC_BODY],[
static StringReader static StringReader
getinput(String filename) throws IOException getinput(String filename) throws IOException
{ {
StringBuilder buf = new StringBuilder(); // Yes, there are better alternatives to StringBuffer. But we
// don't really care about performances here, while portability
// to older Java matters.
StringBuffer buf = new StringBuffer();
FileReader file = new FileReader(filename); FileReader file = new FileReader(filename);
int c; int c;
while ((c=file.read()) > 0) while (0 < (c = file.read()))
buf.append((char)c); buf.append((char)c);
file.close(); file.close();
return new StringReader(buf.toString()); return new StringReader(buf.toString());
@@ -302,6 +305,13 @@ exp:
; ;
]) ])
## ------------------------------------- ##
## Calc parser with api.push-pull both. ##
## ------------------------------------- ##
# Test that the states transitioned by the push parser are the # Test that the states transitioned by the push parser are the
# same as for the pull parser. This test is assumed to work # same as for the pull parser. This test is assumed to work
# if it produces the same partial trace of stack states as is # if it produces the same partial trace of stack states as is
@@ -577,8 +587,9 @@ Stack now 0 7 15
]]) ]])
AT_BISON_CHECK([PUSHPULLFLAG [-o Calc.java Calc.y]]) AT_BISON_CHECK([PUSHPULLFLAG [-o Calc.java Calc.y]])
AT_JAVA_COMPILE([[Calc.java]]) AT_JAVA_COMPILE([[Calc.java]])
#Verify that this is a push parser. # Verify that this is a push parser.
AT_CHECK_JAVA_GREP([[Calc.java]], AT_CHECK_JAVA_GREP([[Calc.java]],
[[.*public void push_parse_initialize().*]]) [[.*public void push_parse_initialize().*]])
# Capture stderr output for comparison purposes. # Capture stderr output for comparison purposes.
@@ -593,6 +604,13 @@ AT_CHECK([[sed -e '/^Stack now.*$/p' -e d ./stderr]],
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_CLEANUP AT_CLEANUP
## ---------------------------------------------------------------- ##
## Calc parser with %locations %code lexer and api.push-pull both. ##
## ---------------------------------------------------------------- ##
# This test looks for location reporting by looking # This test looks for location reporting by looking
# at the lexer output with locations enabled. # at the lexer output with locations enabled.
# It defines a lexer that reports location info. # It defines a lexer that reports location info.