Skip to content

Commit

Permalink
Add more tests for dict.update
Browse files Browse the repository at this point in the history
In particular, add tests with both a positional argument and keyword arguments (to show that the keyword arguments win).

bazelbuild/starlark#18

RELNOTES: None.
PiperOrigin-RevId: 239024409
  • Loading branch information
laurentlb authored and copybara-github committed Mar 18, 2019
1 parent 48fd960 commit 4d65f44
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/starlark/testdata/dict.sky
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4d65f44

Please sign in to comment.