diff options
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.java | 32 |
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'])") |