update NOTICE and LICENSE
[nit.git] / tests / test_variance_ret.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-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 class A
18 fun foo: A
19 do
20 return new A
21 end
22
23 fun bar: B
24 do
25 return new B
26 end
27
28 fun baz: C
29 do
30 return new C(5)
31 end
32
33 redef fun output
34 do
35 'A'.output
36 end
37
38 init do end
39 end
40
41 class B
42 super A
43 redef fun foo: B
44 do
45 return new B
46 end
47 redef fun bar: C
48 do
49 return new C(6)
50 end
51 redef fun baz: C
52 do
53 return new C(7)
54 end
55 redef fun output
56 do
57 'B'.output
58 end
59
60 init do end
61 end
62 class C
63 super B
64 redef fun foo: C
65 do
66 return new C(8)
67 end
68 redef fun bar: C
69 do
70 return new C(9)
71 end
72 redef fun output do i.output
73 var i: Int
74 init (i: Int) do self.i = i
75 end
76 var a = new A
77 var b = new B
78 var ab: A = b
79 var i = new C(5)
80 var ai: A = i
81 var bi: B = i
82
83 a.foo.output
84 a.bar.output
85 a.baz.output
86
87 ab.foo.output
88 ab.bar.output
89 ab.baz.output
90
91 ai.foo.output
92 ai.bar.output
93 ai.baz.output
94
95 b.foo.output
96 b.bar.output
97 b.baz.output
98
99 bi.foo.output
100 bi.bar.output
101 bi.baz.output
102
103 i.foo.output
104 i.bar.output
105 i.baz.output