update NOTICE and LICENSE
[nit.git] / tests / base_var_type_evolution.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2010 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 a do 'A'.output
21 end
22
23 class B
24 super A
25 fun b do 'B'.output
26 end
27
28 class C
29 super A
30 fun c do 'C'.output
31 end
32
33 fun rand: Bool do return true
34
35 var a = new A
36 if rand then
37 a = new B
38 end
39 a.a
40 #alt1#a.b
41 '\n'.output
42
43 a = new B
44 if rand then
45 a = new B
46 #alt2#a = new C
47 #alt3#a = new A
48 end
49 a.a
50 a.b
51 '\n'.output
52
53 a = new A
54 if rand then
55 a = new B
56 #alt4#a = new C
57 else
58 a = new B
59 #alt5#a = new C
60 end
61 a.a
62 a.b
63 '\n'.output
64
65 a = new A
66 if rand then
67 a = new B
68 else
69 a = new C
70 abort#!alt6#
71 end
72 a.a
73 a.b
74 #alt7#a.c
75 '\n'.output
76