--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth foo
+ with bar
+ do
+ 1.output
+ bar #!alt1#
+ #alt2#bar(2)
+ #alt3#var x = bar
+ 4.output
+ end
+end
+
+meth work
+do
+ var a = new A
+ a.foo with do #!alt11#
+ #alt11#a.foo with x do
+ 2.output
+ #alt4#break
+ #alt5#break 'x'
+ #alt6#continue
+ #alt7#continue 'x'
+ #alt8#return
+ #alt9#return 'x'
+ 3.output
+ end
+ #alt10# a.foo
+ 5.output
+end
+
+0.output
+work
+6.output
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth foo
+ with bar(i: Int)
+ do
+ 1.output
+ bar(2) #!alt1#
+ #alt2#bar
+ #alt12#bar('x')
+ #alt3#var x = bar(2)
+ 4.output
+ end
+end
+
+meth work
+do
+ var a = new A
+ a.foo with x do #!alt11#
+ #alt11#a.foo with do
+ x.output
+ #alt4#break
+ #alt5#break 'x'
+ #alt6#continue
+ #alt7#continue 'x'
+ #alt8#return
+ #alt9#return 'x'
+ (x+1).output
+ end
+ #alt10# a.foo
+ 5.output
+end
+
+0.output
+work
+6.output
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth foo(i, j: Int)
+ with bar(k, l: Int, a: A)
+ do
+ i.output
+ bar(i+1, j-1, self)
+ #alt1#bar(i+1, j-1)
+ j.output
+ end
+end
+
+var a = new A
+0.output
+a.foo(1,8) with x, y, b do #!alt2#
+#alt2#a.foo(1,8) with x, y do
+ x.output
+ b.foo(x+1, y-1) with z, t, c do
+ z.output
+ #alt4#break
+ #alt5#break 'x'
+ #alt6#continue
+ #alt7#continue 'x'
+ #alt8#return
+ #alt9#return 'x'
+ t.output
+ end
+ y.output
+end
+9.output
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth foo
+ with bar: Int
+ do
+ 1.output
+ bar.output #!alt1#
+ #alt2#bar(2)
+ #alt3#var x: Char = bar
+ 4.output
+ end
+end
+
+meth work
+do
+ var a = new A
+ a.foo with do #!alt11#
+ #alt11#a.foo with x do
+ 2.output
+ #alt4#break
+ #alt5#break 'x'
+ #alt6#continue
+ #alt7#continue 'x'
+ #alt8#return
+ #alt9#return 'x'
+ continue 3
+ end
+ #alt10# a.foo
+ 5.output
+end
+
+0.output
+work
+6.output
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth foo: Int
+ with bar: Int
+ do
+ 1.output
+ var r = bar
+ 3.output
+ return r
+ end
+end
+
+meth work: Int
+do
+ var a = new A
+ var i = a.foo with do
+ 2.output
+ #alt1#break
+ #alt2#break 'x'
+ #alt3#break 100
+ #alt4#return
+ #alt5#return 'x'
+ #alt6#return 200
+ #alt7#continue
+ #alt8#continue 'x'
+ continue 5 #!alt9#
+ end
+ 4.output
+ return i
+end
+
+0.output
+work.output
+6.output
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth foo: U
+ with bar
+ do
+ return null
+ end
+end
+
+class T
+end
+
+class U
+special T
+end
+
+class V
+special T
+end
+
+class W
+special U
+special V
+end
+
+var a = new A
+
+var t: T
+var u: U
+var v: V
+var w: W
+
+var y: Object
+#alt1#var y: U
+y = a.foo with do 0.output
+y = a.foo with do break t
+y = a.foo with do break u
+y = a.foo with do break v
+y = a.foo with do break w
+y = a.foo with do
+ break t
+ break u
+ break v
+ break w
+end
+y = a.foo with do
+ break u
+ break v
+ break w
+end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+meth repeat(x: Int)
+ with each(i: Int)
+do
+ var c = 0
+ while c < x do
+ each(c)
+ c += 1
+ end
+end
+
+meth work
+do
+ repeat(4) with i do
+ i.output
+ repeat(4) with j do
+ if i == 1 and j == 1 then continue
+ if i == 2 and j == 2 then break
+ if i == 3 and j == 3 then return
+ ' '.output
+ j.output
+ end
+ if i == 0 then continue
+ '\n'.output
+ end
+end
+
+work
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth foo(i: Int)
+ with bar
+ do
+ '['.output
+ i.output
+ bar with do
+ '!'.output
+ i.output
+ end
+ ']'.output
+ i.output
+ end
+end
+
+meth start
+do
+ var a = new A
+ 0.output
+ a.foo(1) with do
+ 2.output
+ a.foo(3) with do
+ 4.output
+ #alt1#break
+ #alt2#continue
+ #alt3#return
+ 5.output
+ end
+ 6.output
+ end
+ 7.output
+end
+
+start
+8.output
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ meth indent(i: Int, j, c: Char)
+ do
+ var ii = i
+ while ii > 0 do
+ ' '.output
+ ii -= 1
+ end
+ c.output
+ j.output
+ ','.output
+ i.output
+ end
+
+ meth foo(i: Int, j: Char)
+ with bar
+ do
+ if i >= 3 then
+ indent(i, j, '{')
+ bar
+ indent(i, j, '}')
+ return
+ end
+
+ indent(i, j, '[')
+ foo(i+1, 'a') with do
+ foo(i+1, 'b') with do
+ foo(i+1, 'c') with do
+ indent(i, j, '<')
+ bar
+ indent(i, j, '>')
+ end
+ end
+ end
+ indent(i, j, ']')
+ end
+end
+
+meth start
+do
+ var a = new A
+ 0.output
+ a.foo(0, 'A') with do
+ a.foo(0, 'B') with do
+ a.foo(0, 'C') with do
+ 1.output
+ #alt1# break
+ #alt2# return
+ end
+ end
+ end
+ 2.output
+end
+
+start
+3.output
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+meth a
+ with a1
+ with a2 #!alt1#
+#alt2# with a3
+do
+ a1
+ a2 #!alt1#
+#alt2# a3
+end
+
+meth b
+ with b1
+ with b2
+do
+ b1
+ b2
+end
+
+meth c
+ with c1
+do
+ c1
+end
+
+meth d
+ with d1
+ with d2
+ with d3
+do
+ d1
+ d2
+ d3
+end
+
+0.output
+a with do
+ b with do
+ 1.output
+ with do #!alt3#
+ 2.output #!alt3#
+#alt4# with do
+#alt4# 20.output
+ end
+with do
+ 3.output
+end
+4.output
+c with do
+ d with do
+ 5.output
+ with do
+ 6.output
+ with do 7.output
+end
+8.output
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+redef class Range[K]
+ meth for_each(x: Int)
+ with each(i: K)
+ do
+ var c = first
+ var s = after
+ while c < s do
+ #print((" " * x) + c.to_s)
+ each(c)
+ c = c.succ
+ end
+ end
+end
+
+var nb = 5
+if not args.is_empty then nb = args.first.to_i
+
+var cpt = 0
+var r = [0..nb[
+r.for_each(0) with ii1 do
+ r.for_each(1) with ii2 do
+ r.for_each(2) with ii3 do
+ if ii1 == ii2 and ii2 == ii3 then cpt += 1
+ end
+ end
+end
+
+print cpt
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var nb = 5
+if not args.is_empty then nb = args.first.to_i
+
+var cpt = 0
+var r = [0..nb[
+var i1 = r.iterator
+while i1.is_ok do
+ var ii1 = i1.item
+
+ var i2 = r.iterator
+ while i2.is_ok do
+ var ii2 = i2.item
+
+ var i3 = r.iterator
+ while i3.is_ok do
+ var ii3 = i3.item
+
+ if ii1 == ii2 and ii2 == ii3 then cpt += 1
+
+ i3.next
+ end
+
+ i2.next
+ end
+ i1.next
+end
+
+print cpt
--- /dev/null
+alt/base_closure1_alt10.nit:45,3--7: Error: property foo requires 1 blocs.
--- /dev/null
+alt/base_closure1_alt11.nit:34,8--42:10: Error: 0 automatic variable names expected, 1 found.
--- /dev/null
+alt/base_closure1_alt2.nit:25,3--7: Error: 'bar' arity missmatch.
--- /dev/null
+alt/base_closure1_alt3.nit:26,11--13: Type error: expected expression.
--- /dev/null
+alt/base_closure1_alt5.nit:38,3--11: Error: break without value required in this bloc.
--- /dev/null
+alt/base_closure1_alt7.nit:40,3--14: Error: continue without value required in this bloc.
--- /dev/null
+alt/base_closure1_alt9.nit:42,3--12: Error: Return with value in a procedure.
--- /dev/null
+alt/base_closure2_alt10.nit:46,3--7: Error: property foo requires 1 blocs.
--- /dev/null
+alt/base_closure2_alt11.nit:35,8--43:14: Error: 1 automatic variable names expected, 0 found.
--- /dev/null
+alt/base_closure2_alt12.nit:26,7--9: Type error: expected Int, got Char
--- /dev/null
+alt/base_closure2_alt2.nit:25,3--5: Error: 'bar' arity missmatch.
--- /dev/null
+alt/base_closure2_alt3.nit:27,11--15: Type error: expected expression.
--- /dev/null
+alt/base_closure2_alt5.nit:39,3--11: Error: break without value required in this bloc.
--- /dev/null
+alt/base_closure2_alt7.nit:41,3--14: Error: continue without value required in this bloc.
--- /dev/null
+alt/base_closure2_alt9.nit:43,3--12: Error: Return with value in a procedure.
--- /dev/null
+alt/base_closure3_alt1.nit:25,3--14: Error: 'bar' arity missmatch.
--- /dev/null
+alt/base_closure3_alt2.nit:32,12--44:9: Error: 3 automatic variable names expected, 2 found.
--- /dev/null
+alt/base_closure3_alt5.nit:38,3--11: Error: break without value required in this bloc.
--- /dev/null
+alt/base_closure3_alt7.nit:40,3--14: Error: continue without value required in this bloc.
--- /dev/null
+alt/base_closure3_alt9.nit:42,3--12: Error: Return with value in a procedure.
--- /dev/null
+alt/base_closure4_alt10.nit:45,3--7: Error: property foo requires 1 blocs.
--- /dev/null
+alt/base_closure4_alt11.nit:34,8--42:12: Error: 0 automatic variable names expected, 1 found.
--- /dev/null
+alt/base_closure4_alt2.nit:25,3--7: Error: 'bar' arity missmatch.
--- /dev/null
+alt/base_closure4_alt3.nit:26,17--19: Type error: expected Char, got Int
--- /dev/null
+alt/base_closure4_alt5.nit:38,3--11: Error: break without value required in this bloc.
--- /dev/null
+alt/base_closure4_alt6.nit:39,3--10: Error: continue with a value required in this bloc.
--- /dev/null
+alt/base_closure4_alt7.nit:40,12--14: Type error: expected Int, got Char
--- /dev/null
+alt/base_closure4_alt9.nit:42,3--12: Error: Return with value in a procedure.
--- /dev/null
+alt/base_closure5_alt1.nit:35,3--7: Error: break with a value required in this bloc.
--- /dev/null
+alt/base_closure5_alt2.nit:36,9--11: Type error: expected Int, got Char
--- /dev/null
+alt/base_closure5_alt4.nit:38,3--8: Error: Return without value in a function.
--- /dev/null
+alt/base_closure5_alt5.nit:39,10--12: Type error: expected Int, got Char
--- /dev/null
+alt/base_closure5_alt7.nit:41,3--10: Error: continue with a value required in this bloc.
--- /dev/null
+alt/base_closure5_alt8.nit:42,12--14: Type error: expected Int, got Char
--- /dev/null
+alt/base_closure5_alt9.nit:33,16--34:10: Control error: Reached end of bloc (a 'continue' with a value was expected).
--- /dev/null
+./base_closure6.nit:55,25--25: Type error: expected U, got V
+./base_closure6.nit:65,8--8: Type error: expected U, got V
--- /dev/null
+alt/base_closure6_alt1.nit:53,5--25: Type error: expected U, got T
+alt/base_closure6_alt1.nit:55,25--25: Type error: expected U, got V
+alt/base_closure6_alt1.nit:57,5--61:8: Type error: expected U, got T
+alt/base_closure6_alt1.nit:65,8--8: Type error: expected U, got V
--- /dev/null
+alt/base_closure_multi_alt1.nit:52,1--61:9: Error: property a requires 1 blocs, 2 found.
--- /dev/null
+alt/base_closure_multi_alt2.nit:54,1--63:9: Error: property a requires 3 blocs, 2 found.
--- /dev/null
+alt/base_closure_multi_alt3.nit:55,2--56:10: Error: property b requires 2 blocs, 1 found.
--- /dev/null
+alt/base_closure_multi_alt4.nit:55,2--60:11: Error: property b requires 2 blocs, 3 found.