OILS / mycpp / examples / test_func_method_name_conflict.py View on Github | oils.pub

69 lines, 33 significant
1#!/usr/bin/env python2
2"""
3test_func_method_name_conflict.py
4"""
5
6import os
7
8
9def a():
10 # type: () -> int
11 return 1
12
13
14class MethodDefinedBefore:
15
16 def __init__(self):
17 # type: () -> None
18 pass
19
20 def a(self):
21 # type: () -> int
22 raise AssertionError()
23 return 1
24
25 def b(self):
26 # type: () -> None
27 a() # should call the free function
28
29
30class MethodDefinedAfter:
31
32 def __init__(self):
33 # type: () -> None
34 pass
35
36
37 def b(self):
38 # type: () -> None
39 c() # should call the free function
40
41 def c(self):
42 # type: () -> int
43 raise AssertionError()
44 return 1
45
46
47def c():
48 # type: () -> int
49 return a()
50
51
52def run_tests():
53 # type: () -> None
54 before = MethodDefinedBefore()
55 before.b()
56 after = MethodDefinedAfter()
57 after.b()
58
59
60def run_benchmarks():
61 # type: () -> None
62 pass
63
64
65if __name__ == '__main__':
66 if os.getenv('BENCHMARK'):
67 run_benchmarks()
68 else:
69 run_tests()