update NOTICE and LICENSE
[nit.git] / tests / base_vararg.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-2009 Jean Privat <jean@pryen.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 array
18
19 fun foo(a: Char...)
20 do
21 for x in a do x.output
22 '\n'.output
23 end
24
25 fun bar(b: Char, a: Char...)
26 do
27 b.output
28 ','.output
29 for x in a do x.output
30 '\n'.output
31 end
32
33 fun baz(a: Char..., b: Char)
34 do
35 for x in a do x.output
36 ','.output
37 b.output
38 '\n'.output
39 end
40
41 fun foobar(b: Char, a: Char..., c: Char)
42 do
43 b.output
44 ','.output
45 for x in a do x.output
46 ','.output
47 c.output
48 '\n'.output
49 end
50
51 #alt1#foo
52 foo('1')
53 foo('1','2')
54 #alt2#bar
55 #alt3#bar('1')
56 bar('1','2')
57 bar('1','2','3')
58 #alt4#baz
59 #alt5#baz('1')
60 baz('1','2')
61 baz('1','2','3')
62 #alt6#foobar
63 #alt7#foobar('1')
64 #alt8#foobar('1','2')
65 foobar('1','2','3')
66 foobar('1','2','3','4')