Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / bench_send.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 class A
19 var val: Int = 0
20 fun hop(a: A, b: A, c: A)
21 do
22 if a.val > val then
23 a.hop(b, c, self)
24 end
25 foo(a, b)
26 foo(a, c)
27 foo(b, c)
28 foo(c, b)
29 end
30 fun foo(a: A, b: A)
31 do
32 if a.val > val then
33 a.foo(b, self)
34 end
35 bar(a)
36 bar(b)
37 end
38 fun bar(a: A)
39 do
40 if a.val > val then
41 a.bar(self)
42 end
43 baz
44 end
45 fun baz
46 do
47 i += 1
48 end
49
50 var i = 0
51
52 init
53 do
54 end
55 end
56
57 class B
58 super A
59 redef fun val: Int
60 do
61 return 1
62 end
63
64 init
65 do
66 end
67 end
68
69 class C
70 super A
71 redef fun val: Int
72 do
73 return 2
74 end
75
76 init
77 do
78 end
79 end
80
81 class D
82 super A
83 redef fun val: Int
84 do
85 return 3
86 end
87
88 init
89 do
90 end
91 end
92
93 var a = new A
94 var b = new B
95 var c = new C
96 var d = new D
97
98 a.val = 0
99 b.val = 1
100 c.val = 2
101 d.val = 3
102 var i = 0
103
104 var n = 10
105 if args.not_empty then n = args.first.to_i
106
107 while i < 1 << n do
108 a.hop(b, c, d)
109 i = i + 1
110 end
111
112 print a.i
113 print b.i
114 print c.i
115 print d.i