Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_virtual_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 fun test(d: A)
35 do
36 d.foo(5).output
37 #alt1#3.foo(d).output
38 d.foo(d).output
39 #alt2#d.foo('a').output
40 #alt3#5.as(A).foo(d).output
41 end
42
43 test(4)