Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_covar_int2.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 interface A
18 type V: A
19 fun foo(v: V): V is abstract
20 end
21
22 redef class Int
23 super A
24 redef type V: Int
25 redef fun foo(v) do return self
26 end
27
28 redef class Char
29 super A
30 redef type V: Char
31 redef fun foo(v) do return self
32 end
33
34 var d1: A = 1
35 var d2: A = 2
36 var c1: A = 'a'
37 var c2: A = 'b'
38 1.foo(2).output
39 d1.foo(2).output
40 #alt1#c1.foo(2).output
41 #alt2#1.foo(d2).output
42 d1.foo(d2).output
43 #alt3#c1.foo(d2).output
44 #alt4#1.foo(c2).output
45 #alt5#d1.foo(c2).output
46 c1.foo(c2).output
47 '\n'.output