diff options
author | Damien George <damien.p.george@gmail.com> | 2015-05-12 23:08:18 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-12 23:08:18 +0100 |
commit | 7bab32ef89d760a8cf4aeb2700725ea88e3fc31c (patch) | |
tree | 08dbed7356ce29a140e8506a0d13d69d094454cb | |
parent | c50772d19fe2804a6d0258f89dd9967d3b516fd3 (diff) | |
download | micropython-7bab32ef89d760a8cf4aeb2700725ea88e3fc31c.tar.gz micropython-7bab32ef89d760a8cf4aeb2700725ea88e3fc31c.zip |
tests: Add further tests for class defining __hash__.
-rw-r--r-- | tests/basics/builtin_hash.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/basics/builtin_hash.py b/tests/basics/builtin_hash.py index b6b2ad15cb..76fb183044 100644 --- a/tests/basics/builtin_hash.py +++ b/tests/basics/builtin_hash.py @@ -42,3 +42,15 @@ try: hash(D()) except TypeError: print("TypeError") + +# __hash__ returning a bool should be converted to an int +class E: + def __hash__(self): + return True +print(hash(E())) + +# __hash__ returning a large number should be truncated +class F: + def __hash__(self): + return 1 << 70 | 1 +print(hash(F()) != 0) |