Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_arg_default.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 core::kernel
16
17 class A
18 fun foo(a, b: nullable Int, c, d: Int, e,f: nullable Int)
19 do
20 if a == null then '\n'.output else a.output
21 if b == null then '\n'.output else b.output
22 c.output
23 d.output
24 if e == null then '\n'.output else e.output
25 if f == null then '\n'.output else f.output
26 '-'.output
27 '\n'.output
28
29 end
30
31 fun bar(a,b,c: nullable Int)
32 do
33 if a == null then '\n'.output else a.output
34 if b == null then '\n'.output else b.output
35 if c == null then '\n'.output else c.output
36 '-'.output
37 '\n'.output
38 end
39
40 fun bar=(a,b,c: nullable Int)
41 do
42 if a == null then '\n'.output else a.output
43 if b == null then '\n'.output else b.output
44 if c == null then '\n'.output else c.output
45 '-'.output
46 '\n'.output
47 end
48
49 fun [](a,b,c: nullable Int): Int
50 do
51 if a == null then '\n'.output else a.output
52 if b == null then '\n'.output else b.output
53 if c == null then '\n'.output else c.output
54 '-'.output
55 '\n'.output
56 return 0
57 end
58
59 fun []=(a,b,c: nullable Int): Int
60 do
61 if a == null then '\n'.output else a.output
62 if b == null then '\n'.output else b.output
63 if c == null then '\n'.output else c.output
64 '-'.output
65 '\n'.output
66 return 0
67 end
68
69 fun +(a: nullable Int): Int
70 do
71 if a == null then '\n'.output else a.output
72 '-'.output
73 '\n'.output
74 return 0
75 end
76 end
77
78 var a = new A
79 var x
80
81 #alt1#a.foo
82 #alt1#a.foo(2)
83 #alt1#a.foo(1,2)
84 #alt1#a.foo(1,2,3)
85 a.foo(1,2,3,4)
86 a.foo(1,2,3,4,5)
87 a.foo(1,2,3,4,5,6)
88 #alt1#a.foo(1,2,3,4,5,6,7)
89
90 a.bar
91 a.bar(1)
92 a.bar(1,2)
93 a.bar(1,2,3)
94 #alt1#a.bar(1,2,3,4)
95
96 a.bar= 10
97 a.bar(1) = 20
98 a.bar(1,2) = 30
99 #alt1#a.bar(1,2,3) = 40
100
101 #alt2# x = a[]
102 x = a[1]
103 x = a[1,2]
104 x = a[1,2,3]
105 #alt2#x = a[1,2,3,4]
106
107 #alt2#a[] = 10
108 a[1] = 20
109 a[1,2] = 30
110 #alt1#a[1,2,3] = 40