Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_vararg2.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 array
16
17 class G[E]
18 fun foo(es:E...)
19 do
20 es.output_class_name
21 ' '.output
22 es[0].output_class_name
23 ' '.output
24 es[1].output_class_name
25 end
26 end
27
28 class X[T:G[nullable Object],U]
29 fun bar(t: T, u: U)
30 do
31 t.foo(u, u)
32 end
33 end
34
35 var go = new G[Object]
36 go.foo(1, true)
37
38 var gi = new G[Int]
39 gi.foo(1, 2)
40
41 var goi: G[Object] = new G[Int]
42 goi.foo(1, 2)
43 #alt1#goi.foo(1, true)
44
45 var xgoo = new X[G[Object], Object]
46 xgoo.bar(go, 1)
47 xgoo.bar(gi, 1)
48 xgoo.bar(goi, 1)
49 xgoo.bar(go, true)
50 #alt2#xgoo.bar(gi, true)
51 #alt3#xgoo.bar(goi, true)
52
53 var xgoi = new X[G[Object], Int]
54 xgoi.bar(go, 1)
55 xgoi.bar(gi, 1)
56 xgoi.bar(goi, 1)
57 var gb: G[Object] = new G[Bool]
58 #alt4#xgoi.bar(gb, 1)
59
60 var xgio = new X[G[Int], Object]
61 xgio.bar(gi, 1)
62 #alt5#xgio.bar(gi, true)
63
64 var xgii = new X[G[Int], Object]
65 xgii.bar(gi, 1)