From 7bab32ef89d760a8cf4aeb2700725ea88e3fc31c Mon Sep 17 00:00:00 2001 From: Damien George <damien.p.george@gmail.com> Date: Tue, 12 May 2015 23:08:18 +0100 Subject: [PATCH] tests: Add further tests for class defining __hash__. --- tests/basics/builtin_hash.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/basics/builtin_hash.py b/tests/basics/builtin_hash.py index b6b2ad15c..76fb18304 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) -- GitLab