Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / test_array_formal.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 class G[E]
16 type T: nullable Object
17
18 fun ae(e: E): Object do return [e]
19 fun at(t: T): Object do return [t]
20 fun ae2: Object do return new Array[E]
21 fun at2: Object do return new Array[T]
22 end
23
24 class GO
25 super G[Object]
26 redef type T: Object
27 end
28
29 class GI
30 super G[Int]
31 redef type T: Int
32 end
33
34 fun test(x: Object)
35 do
36 (x isa Array[nullable Object]).output
37 (x isa Array[Object]).output
38 (x isa Array[Int]).output
39 '\n'.output
40 end
41
42 fun test2(x: G[Object])
43 do
44 test(x.ae(1))
45 test(x.ae2)
46 test(x.at(2))
47 test(x.at2)
48 '\n'.output
49 end
50
51 test2(new GO)
52 test2(new GI)
53 test2(new G[Object])