Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_inheritance.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 end
16
17 interface Object
18 end
19
20 enum Int
21 fun output is intern
22 end
23
24 class A
25 fun foo do 1.output
26 end
27
28 class B
29 super A
30 end
31
32 class C
33 super B
34 redef fun foo do 2.output
35 end
36
37 class D
38 super C
39 end
40
41 class D2
42 super C
43 redef fun foo do 3.output
44 end
45
46 class E
47 super D
48 super D2
49 end
50
51 fun test(a: A)
52 do
53 a.foo
54 end
55
56 test(new A)
57 test(new B)
58 test(new C)
59 test(new D)
60 test(new D2)
61 test(new E)