diff options
author | 2017-05-19 21:18:25 +0200 | |
---|---|---|
committer | 2017-05-22 14:38:29 +0200 | |
commit | 094bb2685f41ab3cddba382a1e8796ee8e3cd095 (patch) | |
tree | 092a6eb6d2d26857b72ddb31f52e58456ba5202c /src/test/java | |
parent | f039788b63507ac0ffa27bba131a36b1c49e7673 (diff) |
Add operator // for division.
In both Python 2 and Python 3, the operator // is used for int division.
With Python 3, operator / is for float division.
RELNOTES: None.
PiperOrigin-RevId: 156582262
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java | 14 |
1 files changed, 14 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 0f2a2cbb17..6e826bd766 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 @@ -322,6 +322,20 @@ public class EvaluationTest extends EvaluationTestCase { } @Test + public void testFloorDivision() throws Exception { + newTest() + .testStatement("6 // 2", 3) + .testStatement("6 // 4", 1) + .testStatement("3 // 6", 0) + .testStatement("7 // -2", -4) + .testStatement("-7 // 2", -4) + .testStatement("-7 // -2", 3) + .testStatement("2147483647 // 2", 1073741823) + .testIfErrorContains("unsupported operand type(s) for /: 'string' and 'int'", "'str' / 2") + .testIfExactError("integer division by zero", "5 // 0"); + } + + @Test public void testOperatorPrecedence() throws Exception { newTest() .testStatement("2 + 3 * 4", 14) |