Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_redef.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 core::kernel
16
17 class A
18 fun f do 1.output
19 fun f2: Int do return 2
20 fun f2=(i:Int) do i.output
21 fun f3=(i:Int) do i.output
22 var v = 4
23 type T: A
24 fun t(t: T): T do return t
25 end
26
27 class B
28 super A#alt1#
29 redef fun f do 10.output
30 redef var f2 = 20
31 var f3 = 30 is redef writable
32 redef var v = 40
33 redef type T: B
34 end
35
36 class C
37 super B#alt2#
38 redef fun f do 100.output
39 redef var f2 = 200
40 redef var f3 = 300
41 redef var v = 400
42 redef type T: C
43
44 end
45
46 var a = new A
47 a.f
48 a.f2 = -2
49 a.f2.output
50 a.f3 = -3
51 a.t(a).f
52
53 a = new B
54 a.f
55 a.f2 = -2
56 a.f2.output
57 a.f3 = -3
58 a.t(a).f
59
60 a = new C
61 a.f
62 a.f2 = -2
63 a.f2.output
64 a.f3 = -3
65 a.t(a).f