diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java | 33 |
1 files changed, 23 insertions, 10 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 72fd205ecf..de926812a7 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 @@ -123,8 +123,8 @@ public class MethodLibraryTest extends EvaluationTestCase { + "but should be string", "'test'.startswith(1)") .testIfErrorContains( - "Method dict(args: Iterable, **kwargs) is not applicable for arguments " - + "(string, dict): 'args' is string, but should be Iterable", + "expected value of type 'list(object)' for parameter args in dict(), " + + "but got \"a\" (string)", "dict('a')"); } @@ -647,6 +647,20 @@ public class MethodLibraryTest extends EvaluationTestCase { } @Test + public void testDictionaryCopy() throws Exception { + new SkylarkTest() + .setUp("x = {1 : 2}", "y = dict(x)") + .testEval("x[1] == 2 and y[1] == 2", "True"); + } + + @Test + public void testDictionaryCopyKeyCollision() throws Exception { + new SkylarkTest() + .setUp("x = {'test' : 2}", "y = dict(x, test = 3)") + .testEval("y['test']", "3"); + } + + @Test public void testDictionaryWithMultipleKeys() throws Exception { new BothModesTest().testStatement("{0: 'a', 1: 'b', 0: 'c'}[0]", "c"); } @@ -741,19 +755,18 @@ public class MethodLibraryTest extends EvaluationTestCase { @Test public void testDictionaryCreationInvalidPositional() throws Exception { - String unexpectedString = - "expected value of type 'list(object)' for dict(args), but got \"a\" (string)"; - new BothModesTest() .testIfErrorContains( - "Method dict(args: Iterable, **kwargs) is not applicable for arguments " - + "(string, dict): 'args' is string, but should be Iterable", + "expected value of type 'list(object)' for parameter args in dict(), " + + "but got \"a\" (string)", "dict('a')") - .testIfErrorContains(unexpectedString, "dict(['a'])") - .testIfErrorContains(unexpectedString, "dict([('a')])") + .testIfErrorContains( + "Cannot convert dictionary update sequence element #0 to a sequence", "dict(['a'])") + .testIfErrorContains( + "Cannot convert dictionary update sequence element #0 to a sequence", "dict([('a')])") .testIfErrorContains("too many (3) positional arguments", "dict((3,4), (3,2), (1,2))") .testIfErrorContains( - "Tuple has length 3, but exactly two elements are required", + "Sequence #0 has length 3, but exactly two elements are required", "dict([('a', 'b', 'c')])"); } |