summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/special_comparisons.py
blob: 2ebd7e224efda901f03494bb9963e5a47a5af332 (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
32
33
class A:
    def __eq__(self, other):
        print("A __eq__ called")
        return True

class B:
    def __ne__(self, other):
        print("B __ne__ called")
        return True

class C:
    def __eq__(self, other):
        print("C __eq__ called")
        return False

class D:
    def __ne__(self, other):
        print("D __ne__ called")
        return False

a = A()
b = B()
c = C()
d = D()

def test(s):
    print(s)
    print(eval(s))

for x in 'abcd':
    for y in 'abcd':
        test('{} == {}'.format(x,y))
        test('{} != {}'.format(x,y))