Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_ret_covar_int.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 kernel
16
17 class A[E]
18 type V: Object
19 fun foo: Object do return 1
20
21 fun bar1: E do return 2
22 fun bar2: E do return 3
23
24 fun baz1: V do return 4
25 fun baz2: V do return 5
26 end
27
28 class B
29 super A[Int]
30 redef type V: Int
31
32 redef fun foo: Int do return 11
33
34 redef fun bar1 do return 22
35 redef fun bar2: Int do return 33
36
37 redef fun baz1 do return 44
38 #alt1#redef fun baz2 do return 55
39 end
40
41 fun test_a(a: A[Object])
42 do
43 a.foo.output
44 a.bar1.output
45 a.bar2.output
46 a.baz1.output
47 a.baz2.output
48 end
49 fun test_b(a: B)
50 do
51 a.foo.output
52 a.bar1.output
53 a.bar2.output
54 a.baz1.output
55 a.baz2.output
56 end
57
58 var a = new A[Object]
59 test_a(a)
60
61 a = new A[Int]
62 test_a(a)
63
64 a = new B
65 test_a(a)
66 test_b(a)