summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/class_binop.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/class_binop.py')
-rw-r--r--tests/basics/class_binop.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/basics/class_binop.py b/tests/basics/class_binop.py
new file mode 100644
index 0000000000..774f0afaf9
--- /dev/null
+++ b/tests/basics/class_binop.py
@@ -0,0 +1,31 @@
+class foo(object):
+ def __init__(self, value):
+ self.x = value
+
+ def __eq__(self, other):
+ print('eq')
+ return self.x == other.x
+
+ def __lt__(self, other):
+ print('lt')
+ return self.x < other.x
+
+ def __gt__(self, other):
+ print('gt')
+ return self.x > other.x
+
+ def __le__(self, other):
+ print('le')
+ return self.x <= other.x
+
+ def __ge__(self, other):
+ print('ge')
+ return self.x >= other.x
+
+for i in range(3):
+ for j in range(3):
+ print(foo(i) == foo(j))
+ print(foo(i) < foo(j))
+ print(foo(i) > foo(j))
+ print(foo(i) <= foo(j))
+ print(foo(i) >= foo(j))