summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/class_contains.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-07-05 06:14:29 +0100
committerDamien George <damien.p.george@gmail.com>2014-07-05 06:14:29 +0100
commit539681fffd96082ca3b5d18643d4f08f65c47170 (patch)
tree7e6f8332c6e7737b768750e67265bb02b22932e6 /tests/basics/class_contains.py
parent0182385ab0b4a1b2e549c92f8f5b621135aeb975 (diff)
downloadmicropython-539681fffd96082ca3b5d18643d4f08f65c47170.tar.gz
micropython-539681fffd96082ca3b5d18643d4f08f65c47170.zip
tests: Rename test scripts, changing - to _ for consistency.
From now on, all new tests must use underscore. Addresses issue #727.
Diffstat (limited to 'tests/basics/class_contains.py')
-rw-r--r--tests/basics/class_contains.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/basics/class_contains.py b/tests/basics/class_contains.py
new file mode 100644
index 0000000000..b6dd3661cd
--- /dev/null
+++ b/tests/basics/class_contains.py
@@ -0,0 +1,23 @@
+# A contains everything
+class A:
+ def __contains__(self, key):
+ return True
+
+a = A()
+print(True in a)
+print(1 in a)
+print(() in a)
+
+# B contains given things
+class B:
+ def __init__(self, items):
+ self.items = items
+ def __contains__(self, key):
+ return key in self.items
+
+b = B([])
+print(1 in b)
+b = B([1, 2])
+print(1 in b)
+print(2 in b)
+print(3 in b)