Skylark: implement dict.update
--
MOS_MIGRATED_REVID=116553978
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 1935a7e..55b0de2 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
@@ -443,10 +443,11 @@
@Test
public void testDir() throws Exception {
- new SkylarkTest().testStatement(
- "str(dir({}))",
- "[\"$index\", \"clear\", \"get\", \"items\", \"keys\","
- + " \"pop\", \"popitem\", \"setdefault\", \"values\"]");
+ new SkylarkTest()
+ .testStatement(
+ "str(dir({}))",
+ "[\"$index\", \"clear\", \"get\", \"items\", \"keys\","
+ + " \"pop\", \"popitem\", \"setdefault\", \"update\", \"values\"]");
}
@Test
@@ -1360,6 +1361,16 @@
}
@Test
+ public void testDictionaryUpdate() throws Exception {
+ new BothModesTest()
+ .setUp("foo = {'a': 2}")
+ .testEval("foo.update({'b': 4}); foo", "{'a': 2, 'b': 4}");
+ new BothModesTest()
+ .setUp("foo = {'a': 2}")
+ .testEval("foo.update({'a': 3, 'b': 4}); foo", "{'a': 3, 'b': 4}");
+ }
+
+ @Test
public void testDictionarySetDefault() throws Exception {
new SkylarkTest()
.testEval(