summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-01-31 06:34:50 +0100
committerAkim Demaille <akim.demaille@gmail.com>2020-02-02 11:32:55 +0100
commitd5f929d407012ea6cb3cdc19b0a0406d40cf921f (patch)
tree5318895b8e115a7d9ecb2bc8be2b61a953430916 /tests
parentc5b215b5e6a8272e71ee79225ed0ea953f773652 (diff)
downloadbison-d5f929d407012ea6cb3cdc19b0a0406d40cf921f.tar.gz
java: example: rely on autoboxing
AFAICT, autoboxing/unboxing was added in Java 5 (September 30, 2004). I think we can afford to use it. It should help us merge some Java tests with the main ones. However, beware that != does not unbox: it compares the object addresses. * examples/java/Calc.y, tests/java.at: Simplify. * examples/java/Calc.test, tests/java.at: Improve tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/java.at28
1 files changed, 13 insertions, 15 deletions
diff --git a/tests/java.at b/tests/java.at
index 0383ddd4..61740c25 100644
--- a/tests/java.at
+++ b/tests/java.at
@@ -97,24 +97,22 @@ line:
;
exp:
- NUM { $$ = $1; }
+ NUM { $$ = $1; }
| exp '=' exp
{
if ($1.intValue () != $3.intValue ())
- yyerror (]AT_LOCATION_IF([[@$,]])[ "calc: error: " + $1 + " != " + $3);
+ yyerror (]AT_LOCATION_IF([[@$, ]])["calc: error: " + $1 + " != " + $3);
}
-| exp '+' exp { $$ = new Integer ($1.intValue () + $3.intValue ()); }
-| exp '-' exp { $$ = new Integer ($1.intValue () - $3.intValue ()); }
-| exp '*' exp { $$ = new Integer ($1.intValue () * $3.intValue ()); }
-| exp '/' exp { $$ = new Integer ($1.intValue () / $3.intValue ()); }
-| '-' exp %prec NEG { $$ = new Integer (-$2.intValue ()); }
-| exp '^' exp { $$ = new Integer ((int)
- Math.pow ($1.intValue (),
- $3.intValue ())); }
-| '(' exp ')' { $$ = $2; }
-| '(' error ')' { $$ = new Integer (1111); }
-| '!' { $$ = new Integer (0); return YYERROR; }
-| '-' error { $$ = new Integer (0); return YYERROR; }
+| exp '+' exp { $$ = $1 + $3; }
+| exp '-' exp { $$ = $1 - $3; }
+| exp '*' exp { $$ = $1 * $3; }
+| exp '/' exp { $$ = $1 / $3; }
+| '-' exp %prec NEG { $$ = -$2; }
+| exp '^' exp { $$ = (int) Math.pow ($1, $3); }
+| '(' exp ')' { $$ = $2; }
+| '(' error ')' { $$ = 1111; }
+| '!' { $$ = 0; return YYERROR; }
+| '-' error { $$ = 0; return YYERROR; }
;
]AT_LEXPARAM_IF([[%code lexer {]],
@@ -257,7 +255,7 @@ AT_DATA([[input]],
2^2^3 = 256
(2^2)^3 = 64
]])
-AT_JAVA_PARSER_CHECK([Calc < input], 0, [], [stderr])
+AT_JAVA_PARSER_CHECK([Calc < input])
# Some syntax errors.