From 4d65f4428f662d2bd355e46ca3ba1ea57dc8a827 Mon Sep 17 00:00:00 2001 From: laurentlb Date: Mon, 18 Mar 2019 11:21:02 -0700 Subject: [PATCH] Add more tests for dict.update In particular, add tests with both a positional argument and keyword arguments (to show that the keyword arguments win). https://github.com/bazelbuild/starlark/issues/18 RELNOTES: None. PiperOrigin-RevId: 239024409 --- src/test/starlark/testdata/dict.sky | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/starlark/testdata/dict.sky b/src/test/starlark/testdata/dict.sky index 3ae15dc1c448a4..e47e35e4796f99 100644 --- a/src/test/starlark/testdata/dict.sky +++ b/src/test/starlark/testdata/dict.sky @@ -62,6 +62,17 @@ assert_eq(foo, bar) assert_eq(foo, baz) assert_eq(foo, quz) +d = {"b": 0} +d.update({"a": 1}, b = 2) +d.update({"c": 0}, c = 3) +d.update(d, d = 4) +d.update([("e", 5)]) +d.update((["f", 0],), f = 6) + +expected = {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6} +assert_eq(d, expected) + + # creation with repeated keys d1 = dict([('a', 1)], a=2)