First NIT release and new clean mercurial repository
[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 readable writable attr _val: Int
20 meth 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 meth 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 meth bar(a: A)
39 do
40 if a.val > val then
41 a.bar(self)
42 end
43 baz
44 end
45 meth baz
46 do
47 end
48
49 init
50 do
51 end
52 end
53
54 class B
55 special A
56 redef meth val: Int
57 do
58 return 1
59 end
60
61 redef init
62 do
63 end
64 end
65
66 class C
67 special A
68 redef meth val: Int
69 do
70 return 2
71 end
72
73 redef init
74 do
75 end
76 end
77
78 class D
79 special A
80 redef meth val: Int
81 do
82 return 3
83 end
84
85 redef init
86 do
87 end
88 end
89
90 var a = new A
91 var b = new B
92 var c = new C
93 var d = new D
94
95 a.val = 0
96 b.val = 1
97 c.val = 2
98 d.val = 3
99 var i = 0
100 while i < 100000 do
101 a.hop(b, c, d)
102 i = i + 1
103 end