syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / base_super_linext.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 fun work do
21 foo
22 '\n'.output
23 bar.output
24 '\n'.output
25 end
26 fun foo do 'A'.output
27 fun bar: Char do return 'A'
28 init do end
29 end
30
31 class B
32 special A
33 redef fun foo
34 do
35 'B'.output
36 '['.output
37 super
38 ']'.output
39 end
40 redef fun bar
41 do
42 super.output
43 return 'B'
44 end
45 init do end
46 end
47
48 class C
49 special A
50 redef fun foo
51 do
52 'C'.output
53 '['.output
54 super
55 ']'.output
56 end
57 redef fun bar
58 do
59 super.output
60 return 'C'
61 end
62 init do end
63 end
64
65 class D
66 special B
67 special C
68 redef fun foo
69 do
70 'D'.output
71 '['.output
72 super
73 ']'.output
74 end
75 redef fun bar
76 do
77 super.output
78 return 'D'
79 end
80 init do end
81 end
82
83 (new A).work
84 (new B).work
85 (new C).work
86 (new D).work