Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_isa_vt_gen1.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2012 Alexandre Terrasa <alexandre@moz-code.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 base_minimal
18
19 class Int end
20 class String end
21
22 class Triple[X, Y, Z]
23 end
24
25 class A[T, U]
26 type V: nullable Object
27
28 fun foo: Triple[T, U, V] do
29 var triple = new Triple[T, U, V]
30 assert triple isa Triple[T, U, V] # true
31 return triple
32 end
33
34 fun bar(e: T) do
35 assert e isa V
36 end
37 end
38
39 class B[E] super A[E, E]
40 redef type V: E
41 end
42
43 class C[E] super A[E, E]
44 redef type V: B[E]
45 end
46
47 class D[E] super A[E, E]
48 type W: E
49 redef type V: W
50 end
51
52
53 var a = new A[String, Int]
54 assert a.foo isa Triple[String, Int, nullable Object]
55
56 var b = new B[String]
57 assert b.foo isa Triple[String, String, String]
58
59 var c = new C[String]
60 assert c.foo isa Triple[String, String, B[String]]
61
62 var d = new D[String]
63 assert d.foo isa Triple[String, String, String]
64
65 true.output