aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2015-12-22 17:58:40 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2015-12-22 19:57:46 +0000
commit3a837477b79599263dd0f6284806aed291c7dcfd (patch)
treeac6f7348231b03601820d8e8bbbac556b29deba8 /src/test/java/com/google/devtools/build/lib/syntax
parentd46f474733b048d9ef10dd13ec639b4521693d0a (diff)
Add list.pop
-- MOS_MIGRATED_REVID=110778743
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
index acc3923153..8d90454743 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
@@ -1113,9 +1113,11 @@ public class MethodLibraryTest extends EvaluationTestCase {
@Test
public void testListAccessBadIndex() throws Exception {
- new BothModesTest().testIfErrorContains(
- "expected value of type 'int' for index operand, but got \"a\" (string)",
- "[[1], [2]]['a']");
+ new BothModesTest()
+ .testIfErrorContains(
+ "Method list.$index(key: int) is not applicable for arguments (string): "
+ + "'key' is string, but should be int",
+ "[[1], [2]]['a']");
}
@Test
@@ -1485,6 +1487,30 @@ public class MethodLibraryTest extends EvaluationTestCase {
}
@Test
+ public void testListPop() throws Exception {
+ new BothModesTest()
+ .setUp("li = [2, 3, 4]; ret = li.pop()")
+ .testLookup("li", MutableList.of(env, 2, 3))
+ .testLookup("ret", 4);
+ new BothModesTest()
+ .setUp("li = [2, 3, 4]; ret = li.pop(-2)")
+ .testLookup("li", MutableList.of(env, 2, 4))
+ .testLookup("ret", 3);
+ new BothModesTest()
+ .setUp("li = [2, 3, 4]; ret = li.pop(1)")
+ .testLookup("li", MutableList.of(env, 2, 4))
+ .testLookup("ret", 3);
+ new BothModesTest()
+ .testIfErrorContains(
+ "List index out of range (index is 3, but list has 2 elements)", "[1, 2].pop(3)");
+
+ new BuildTest()
+ .testIfErrorContains(
+ "function pop is not defined on object of type 'tuple'", "(1, 2).pop()");
+ new SkylarkTest().testIfErrorContains("Type tuple has no function pop()", "(1, 2).pop()");
+ }
+
+ @Test
public void testReassignmentOfPrimitivesNotForbiddenByCoreLanguage() throws Exception {
new BuildTest()
.setUp("cc_binary = (['hello.cc'])")