summaryrefslogtreecommitdiff
path: root/tests/basics/class_number.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/class_number.py')
-rw-r--r--tests/basics/class_number.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/basics/class_number.py b/tests/basics/class_number.py
new file mode 100644
index 000000000..e1dbf4a26
--- /dev/null
+++ b/tests/basics/class_number.py
@@ -0,0 +1,15 @@
+# test class with __add__ and __sub__ methods
+
+class C:
+ def __init__(self, value):
+ self.value = value
+
+ def __add__(self, rhs):
+ print(self.value, '+', rhs)
+
+ def __sub__(self, rhs):
+ print(self.value, '-', rhs)
+
+c = C(0)
+c + 1
+c - 2