aboutsummaryrefslogtreecommitdiff
path: root/javatests
diff options
context:
space:
mode:
authorLiam Miller-Cushon <cushon@google.com>2021-09-02 15:51:19 -0700
committerJavac Team <javac-team+copybara@google.com>2021-09-02 15:52:00 -0700
commit32a71bde7db2c338e8ddacc6e59ada3d252b8ad7 (patch)
tree7d681093d4c311f693c2dda4b871435d0ba45709 /javatests
parentd02ef82376fea38853d00de528157a60cbef9a3a (diff)
downloadturbine-32a71bde7db2c338e8ddacc6e59ada3d252b8ad7.tar.gz
Explicitly represent parenthesized expressions in the AST
to fix order of operations when flattening binary trees. Follow-up to https://github.com/google/turbine/commit/fd0a45de2e1c39a2cb774d59c59904caa7040221 PiperOrigin-RevId: 394561504
Diffstat (limited to 'javatests')
-rw-r--r--javatests/com/google/turbine/lower/LowerIntegrationTest.java1
-rw-r--r--javatests/com/google/turbine/lower/testdata/const_operation_order.test13
-rw-r--r--javatests/com/google/turbine/parse/ExpressionParserTest.java6
3 files changed, 17 insertions, 3 deletions
diff --git a/javatests/com/google/turbine/lower/LowerIntegrationTest.java b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
index c0b7253..f832314 100644
--- a/javatests/com/google/turbine/lower/LowerIntegrationTest.java
+++ b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
@@ -125,6 +125,7 @@ public class LowerIntegrationTest {
"const_multi.test",
"const_nonfinal.test",
"const_octal_underscore.test",
+ "const_operation_order.test",
"const_types.test",
"const_underscore.test",
"constlevel.test",
diff --git a/javatests/com/google/turbine/lower/testdata/const_operation_order.test b/javatests/com/google/turbine/lower/testdata/const_operation_order.test
new file mode 100644
index 0000000..a088823
--- /dev/null
+++ b/javatests/com/google/turbine/lower/testdata/const_operation_order.test
@@ -0,0 +1,13 @@
+=== test/A.java ===
+package test;
+
+public class A {
+ public static final double D1 = 1.0 / (2 / 3);
+ public static final double D2 = 1.0 / 2 / 3;
+ public static final double M1 = 1.0 + (2 + 3);
+ public static final double M2 = 1.0 + 2 + 3;
+ public static final double A1 = 1.0 + (2 + 3);
+ public static final double A2 = 1.0 + 2 + 3;
+ public static final double S1 = 1.0 - (2 - 3);
+ public static final double S2 = 1.0 - 2 - 3;
+}
diff --git a/javatests/com/google/turbine/parse/ExpressionParserTest.java b/javatests/com/google/turbine/parse/ExpressionParserTest.java
index 145c9d4..12577fe 100644
--- a/javatests/com/google/turbine/parse/ExpressionParserTest.java
+++ b/javatests/com/google/turbine/parse/ExpressionParserTest.java
@@ -58,7 +58,7 @@ public class ExpressionParserTest {
"(int) 1", "(int) 1",
},
{
- "((1 + 2) + 1)", "(1 + 2 + 1)",
+ "((1 + 2) + 1)", "((1 + 2) + 1)",
},
{
"((Object) 1 + 2)", "((Object) 1 + 2)",
@@ -82,10 +82,10 @@ public class ExpressionParserTest {
"(int) +2", "(int) +2",
},
{
- "(1 + 2) +2", "(1 + 2 + 2)",
+ "(1 + 2) + 2", "((1 + 2) + 2)",
},
{
- "((1 + (2 / 3)) + (4 / 5))", "(1 + (2 / 3) + (4 / 5))",
+ "((1 + (2 / 3)) + (4 / 5))", "((1 + (2 / 3)) + (4 / 5))",
},
{
"(String) \"\"", "(String) \"\"",