aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar laurentlb <laurentlb@google.com>2017-07-03 12:16:15 -0400
committerGravatar John Cater <jcater@google.com>2017-07-05 10:57:16 -0400
commit34bbdcf28261378325307baade7267fcfc32860c (patch)
treeef641af9e7bd720c46cc30cc5cc2d30f8c8054a2 /src/test/java/com/google/devtools/build
parent97a1db383ccf0e4454a3e4703e0dfb30c20201bf (diff)
New flag `--incompatible_checked_arithmetic` to use checked arithmetics.
RELNOTES: Evaluation will soon use checked arithmetics and throw an error instead of overflow/underflow. PiperOrigin-RevId: 160834366
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
index 2ae31358cb..5e9391f54e 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
@@ -217,6 +217,18 @@ public class EvaluationTest extends EvaluationTestCase {
}
@Test
+ public void testCheckedArithmetic() throws Exception {
+ new SkylarkTest("--incompatible_checked_arithmetic=true")
+ .testIfErrorContains("integer overflow", "2000000000 + 2000000000")
+ .testIfErrorContains("integer overflow", "1234567890 * 987654321")
+ .testIfErrorContains("integer overflow", "- 2000000000 - 2000000000")
+
+ // literal 2147483648 is not allowed, so we compute it
+ .setUp("minint = - 2147483647 - 1")
+ .testIfErrorContains("integer overflow", "-minint");
+ }
+
+ @Test
public void testOperatorPrecedence() throws Exception {
newTest()
.testStatement("2 + 3 * 4", 14)