Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_init_autoinit.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 kernel
16
17 class A
18 fun toto(i: Int) is autoinit do
19 'A'.output
20 'o'.output
21 i.output
22 end
23
24 fun tata is autoinit do
25 'A'.output
26 'a'.output
27 '\n'.output
28 end
29
30 init do
31 'A'.output
32 '\n'.output
33 end
34 end
35
36 class B
37 super A
38 fun tutu=(j: Int) is autoinit do
39 # no super here!
40 'B'.output
41 'u'.output
42 j.output
43 end
44
45 redef fun toto(i)
46 do
47 super
48 'B'.output
49 'o'.output
50 i.output
51 end
52
53 redef fun tata do #alt1#redef fun tata is autoinit do
54 'B'.output
55 'a'.output
56 '\n'.output
57 end
58
59 init do
60 'B'.output
61 '\n'.output
62 end
63 end
64
65 class C
66 super A
67 fun tete(k,l: Int) is autoinit do
68 'C'.output
69 'e'.output
70 k.output
71 l.output
72 end
73 end
74
75 var a = new A(1)
76
77 '\n'.output
78
79 var b = new B(10,20)
80
81 '\n'.output
82
83 var c = new C(100,200,300)