diff options
| author | Damien George <damien.p.george@gmail.com> | 2020-02-10 22:22:12 +1100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2020-02-11 11:06:17 +1100 |
| commit | 27465e6b24e80fdcdaddd015fe8f690122f78ef8 (patch) | |
| tree | 5bc93de146462c95e47eaa4374df6195e97d5e8e /tests/basics/dict1.py | |
| parent | 9ec1caf42e7733b5141b7aecf1b6e58834a94bf7 (diff) | |
tests/basics: Add tests for equality between bool and int/float/complex.
False/True should be implicitly converted to 0/1 when compared with numeric
types.
Diffstat (limited to 'tests/basics/dict1.py')
| -rw-r--r-- | tests/basics/dict1.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/basics/dict1.py b/tests/basics/dict1.py index 0cec51173..cd793c9ed 100644 --- a/tests/basics/dict1.py +++ b/tests/basics/dict1.py @@ -23,6 +23,34 @@ print({} == {1:1}) # equality operator on dicts of same size but with different keys print({1:1} == {2:1}) +# 0 replacing False's item +d = {} +d[False] = 'false' +d[0] = 'zero' +print(d) + +# False replacing 0's item +d = {} +d[0] = 'zero' +d[False] = 'false' +print(d) + +# 1 replacing True's item +d = {} +d[True] = 'true' +d[1] = 'one' +print(d) + +# True replacing 1's item +d = {} +d[1] = 'one' +d[True] = 'true' +print(d) + +# mixed bools and integers +d = {False:10, True:11, 2:12} +print(d[0], d[1], d[2]) + # value not found try: {}[0] |
