update NOTICE and LICENSE
[nit.git] / tests / base_closure9.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 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 kernel
18
19 class A
20 fun indent(i: Int, j, c: Char)
21 do
22 var ii = i
23 while ii > 0 do
24 ' '.output
25 ii -= 1
26 end
27 c.output
28 j.output
29 ','.output
30 i.output
31 end
32
33 fun foo(i: Int, j: Char)
34 !bar
35 do
36 if i >= 3 then
37 indent(i, j, '{')
38 bar
39 indent(i, j, '}')
40 return
41 end
42
43 indent(i, j, '[')
44 foo(i+1, 'a') !bar do
45 foo(i+1, 'b') !bar do
46 foo(i+1, 'c') !bar do
47 indent(i, j, '<')
48 bar
49 indent(i, j, '>')
50 end
51 end
52 end
53 indent(i, j, ']')
54 end
55 end
56
57 fun start
58 do
59 var a = new A
60 0.output
61 a.foo(0, 'A') !bar do
62 a.foo(0, 'B') !bar do
63 a.foo(0, 'C') !bar do
64 1.output
65 #alt1# break
66 #alt2# return
67 end
68 end
69 end
70 2.output
71 end
72
73 start
74 3.output