summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/class_binop.py
blob: 774f0afaf91ae9afd46e31e00380852e011bcf56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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))