Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_adaptive_loop_call.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import core::kernel
16
17 class O
18 fun foo: O do
19 0.output
20 return new B
21 end
22 end
23
24 class A
25 super O
26 redef fun foo: B do
27 1.output
28 return new B
29 end
30 fun bar: B do
31 10.output
32 return new B
33 end
34 end
35
36 class B
37 super O
38 redef fun foo: C do
39 2.output
40 return new C
41 end
42 fun bar: C do
43 20.output
44 return new C
45 end
46 end
47
48 class C
49 super O
50 end
51
52 var a: O #alt1# var a
53
54 a = new A
55 var i = 0
56 while i < 4 do
57 a = a.foo #alt2# a = a.bar
58 i += 1
59 end