syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / base_init_linext2.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 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 import kernel
18
19 class A
20 init inita do
21 'A'.output
22 ' '.output
23 end
24 init init_par(c: Char) do
25 'A'.output
26 '2'.output
27 c.output
28 ' '.output
29 end
30 init init_par3(c: Char) do
31 'A'.output
32 '3'.output
33 c.output
34 ' '.output
35 end
36 fun work do '\n'.output
37 end
38
39 class B
40 special A
41 init initb do
42 'B'.output
43 '1'.output
44 ' '.output
45 inita
46 'B'.output
47 '2'.output
48 ' '.output
49 end
50 init init_par do
51 inita
52 'B'.output
53 '3'.output
54 ' '.output
55 end
56 init init_par2(c: Char) do
57 inita
58 'B'.output
59 '4'.output
60 c.output
61 ' '.output
62 end
63 end
64
65 class C
66 special A
67 init do
68 'C'.output
69 '1'.output
70 ' '.output
71 inita
72 'C'.output
73 '2'.output
74 ' '.output
75 end
76 init init_par(c: Char)
77 do
78 'C'.output
79 '3'.output
80 c.output
81 ' '.output
82 end
83 init init_par3(c: Char)
84 do
85 'C'.output
86 '4'.output
87 c.output
88 ' '.output
89 super
90 'C'.output
91 '5'.output
92 ' '.output
93 end
94 end
95
96 class D
97 special B
98 special C
99 init initd do
100 #alt1# super
101 'D'.output
102 '1'.output
103 ' '.output
104 #alt4# init
105 initb #!alt2#
106 'D'.output
107 '2'.output
108 ' '.output
109 #alt5# initb
110 #alt3# init
111 'D'.output
112 '3'.output
113 ' '.output
114 end
115 end
116
117 (new A.inita).work
118 (new A.init_par('x')).work
119 (new B.initb).work
120 (new B.init_par).work
121 (new B.init_par2('y')).work
122 (new C).work
123 (new C.init_par('z')).work
124 (new D.initd).work