diff options
author | laurentlb <laurentlb@google.com> | 2017-07-03 12:16:15 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-07-05 10:57:16 -0400 |
commit | 34bbdcf28261378325307baade7267fcfc32860c (patch) | |
tree | ef641af9e7bd720c46cc30cc5cc2d30f8c8054a2 /src/test/java | |
parent | 97a1db383ccf0e4454a3e4703e0dfb30c20201bf (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')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java | 12 |
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) |