summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-30 10:05:33 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-30 10:05:33 +0000
commit09a0c64bce93f5ebcea82e81b4b07ddd7ff76cc7 (patch)
tree5083bfffe18f07af6a3030199914459684a89a09 /tests
parentb25711ea8fdc1588b5a69f7d0941de09b50fa28c (diff)
downloadmicropython-09a0c64bce93f5ebcea82e81b4b07ddd7ff76cc7.tar.gz
micropython-09a0c64bce93f5ebcea82e81b4b07ddd7ff76cc7.zip
py: Improve __bool__ and __len__ dispatch; add slots for them.
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/slots_bool_len.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/basics/slots_bool_len.py b/tests/basics/slots_bool_len.py
new file mode 100644
index 0000000000..481fe9b4e6
--- /dev/null
+++ b/tests/basics/slots_bool_len.py
@@ -0,0 +1,17 @@
+class A:
+ def __bool__(self):
+ print('__bool__')
+ return True
+ def __len__(self):
+ print('__len__')
+ return 1
+
+class B:
+ def __len__(self):
+ print('__len__')
+ return 0
+
+print(bool(A()))
+print(len(A()))
+print(bool(B()))
+print(len(B()))