summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/dict-del.py21
-rw-r--r--tests/basics/getattr1.py2
-rw-r--r--tests/basics/set_remove.py24
-rw-r--r--tests/basics/types2.py12
4 files changed, 59 insertions, 0 deletions
diff --git a/tests/basics/dict-del.py b/tests/basics/dict-del.py
new file mode 100644
index 0000000000..d908fea424
--- /dev/null
+++ b/tests/basics/dict-del.py
@@ -0,0 +1,21 @@
+for n in range(20):
+ print('testing dict with {} items'.format(n))
+ for i in range(n):
+ # create dict
+ d = dict()
+ for j in range(n):
+ d[str(j)] = j
+ print(len(d))
+
+ # delete an item
+ del d[str(i)]
+ print(len(d))
+
+ # check items
+ for j in range(n):
+ if str(j) in d:
+ if j == i:
+ print(j, 'in d, but it should not be')
+ else:
+ if j != i:
+ print(j, 'not in d, but it should be')
diff --git a/tests/basics/getattr1.py b/tests/basics/getattr1.py
index 7b7e073922..9a96154ca5 100644
--- a/tests/basics/getattr1.py
+++ b/tests/basics/getattr1.py
@@ -13,3 +13,5 @@ a = A()
print(getattr(a, "var"))
print(getattr(a, "var2"))
print(getattr(a, "meth")(5))
+print(getattr(a, "_none_such", 123))
+print(getattr(list, "foo", 456))
diff --git a/tests/basics/set_remove.py b/tests/basics/set_remove.py
index 208ab137f3..5627516c43 100644
--- a/tests/basics/set_remove.py
+++ b/tests/basics/set_remove.py
@@ -1,3 +1,4 @@
+# basic test
s = {1}
print(s.remove(1))
print(list(s))
@@ -7,3 +8,26 @@ except KeyError:
pass
else:
print("failed to raise KeyError")
+
+# test sets of varying size
+for n in range(20):
+ print('testing set with {} items'.format(n))
+ for i in range(n):
+ # create set
+ s = set()
+ for j in range(n):
+ s.add(str(j))
+ print(len(s))
+
+ # delete an item
+ s.remove(str(i))
+ print(len(s))
+
+ # check items
+ for j in range(n):
+ if str(j) in s:
+ if j == i:
+ print(j, 'in s, but it should not be')
+ else:
+ if j != i:
+ print(j, 'not in s, but it should be')
diff --git a/tests/basics/types2.py b/tests/basics/types2.py
new file mode 100644
index 0000000000..83a69c918f
--- /dev/null
+++ b/tests/basics/types2.py
@@ -0,0 +1,12 @@
+# Types are hashable
+print(hash(type) != 0)
+print(hash(int) != 0)
+print(hash(list) != 0)
+class Foo: pass
+print(hash(Foo) != 0)
+
+print(int == int)
+print(int != list)
+
+d = {}
+d[int] = float