First NIT release and new clean mercurial repository
[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 meth 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 'B'.output
52 '3'.output
53 ' '.output
54 end
55 init init_par2(c: Char) do
56 'B'.output
57 '4'.output
58 c.output
59 ' '.output
60 end
61 end
62
63 class C
64 special A
65 init initc do
66 'C'.output
67 '1'.output
68 ' '.output
69 inita
70 'C'.output
71 '2'.output
72 ' '.output
73 end
74 init init_par(c: Char)
75 do
76 'C'.output
77 '3'.output
78 c.output
79 ' '.output
80 end
81 init init_par3(c: Char)
82 do
83 'C'.output
84 '4'.output
85 c.output
86 ' '.output
87 super
88 'C'.output
89 '5'.output
90 ' '.output
91 end
92 end
93
94 class D
95 special B
96 special C
97 init initd do
98 #alt1# super
99 'D'.output
100 '1'.output
101 ' '.output
102 #alt4# initc
103 initb #!alt2#
104 'D'.output
105 '2'.output
106 ' '.output
107 #alt5# initb
108 #alt3# initc
109 'D'.output
110 '3'.output
111 ' '.output
112 end
113 end
114
115 (new A.inita).work
116 (new A.init_par('x')).work
117 (new B.initb).work
118 (new B.init_par).work
119 (new B.init_par2('y')).work
120 (new C.initc).work
121 (new C.init_par('z')).work
122 (new D.initd).work