From: Jean Privat Date: Sat, 16 Nov 2013 15:00:29 +0000 (-0500) Subject: remove closures from code X-Git-Tag: v0.6.4~51^2~6^2~6 X-Git-Url: http://nitlanguage.org remove closures from code Signed-off-by: Jean Privat --- diff --git a/examples/mnit_dino/src/game_logic.nit b/examples/mnit_dino/src/game_logic.nit index fb5418a..abcee06 100644 --- a/examples/mnit_dino/src/game_logic.nit +++ b/examples/mnit_dino/src/game_logic.nit @@ -86,6 +86,7 @@ class Game end # sort for blitting, firsts and in the back + # FIXME: remove closure entities.sort !cmp( a, b ) = b.pos.y <=> a.pos.y return turn diff --git a/lib/counter.nit b/lib/counter.nit index 2812f93..0aaa711 100644 --- a/lib/counter.nit +++ b/lib/counter.nit @@ -59,7 +59,6 @@ class Counter[E: Object] var res = map.keys.to_a var sorter = new CounterSorter[E](self) sorter.sort(res) - #res.sort !cmp a, b = map[a] <=> map[b] return res end diff --git a/lib/curl/curl.nit b/lib/curl/curl.nit index 6b6b34c..b00bb70 100644 --- a/lib/curl/curl.nit +++ b/lib/curl/curl.nit @@ -429,16 +429,6 @@ class HeaderMap return res end - fun iterate !each(k, v: String) - do - var i = arr.iterator - while i.is_ok do - var item = i.item - each(item.first, item.second) - i.next - end - end - fun iterator: MapIterator[String, String] do return new HeaderMapIterator(self) # Convert Self to a single string used to post http fields diff --git a/lib/for_abuse.nit b/lib/for_abuse.nit index ab469a6..a0fb743 100644 --- a/lib/for_abuse.nit +++ b/lib/for_abuse.nit @@ -34,17 +34,6 @@ module for_abuse interface ForAbuser[E] # Starts and control the service fun iterator: Iterator[E] is abstract - - # Starts and contol the service (for `nitc`) - fun iterate - !each(e: E) - do - var i = iterator - while i.is_ok do - each(i.item) - i.next - end - end end # Abuser to read a file, see `file_open` diff --git a/lib/standard/collection/abstract_collection.nit b/lib/standard/collection/abstract_collection.nit index 7318733..8d5cb80 100644 --- a/lib/standard/collection/abstract_collection.nit +++ b/lib/standard/collection/abstract_collection.nit @@ -54,17 +54,6 @@ interface Collection[E] # Get a new iterator on the collection. fun iterator: Iterator[E] is abstract - # Iterate over each element of the collection - fun iterate - !each(e: E) - do - var i = iterator - while i.is_ok do - each(i.item) - i.next - end - end - # Is there no item in the collection? # # assert [1,2,3].is_empty == false @@ -303,17 +292,6 @@ interface MapRead[K: Object, E] # Get a new iterator on the map. fun iterator: MapIterator[K, E] is abstract - # Iterate over each element of the collection - fun iterate - !each(k: K, v: E) - do - var i = iterator - while i.is_ok do - each(i.key, i.item) - i.next - end - end - # Return the point of view of self on the values only. # Note that `self` and `values` are views on the same data; # therefore any modification of one is visible on the other. diff --git a/lib/standard/collection/array.nit b/lib/standard/collection/array.nit index 7b75ccd..5de71cd 100644 --- a/lib/standard/collection/array.nit +++ b/lib/standard/collection/array.nit @@ -250,18 +250,6 @@ class Array[E] super AbstractArray[E] super ArrayCapable[E] - redef fun iterate - !each(e: E) - do - var i = 0 - var l = _length - var items = _items - while i < length do - each(items[i]) - i += 1 - end - end - redef fun [](index) do assert index: index >= 0 and index < _length @@ -363,58 +351,6 @@ class Array[E] # The size of `_items`. var _capacity: Int = 0 - - # Sort the array using the !cmp function. - fun sort - !cmp(e1,e2: E): Int - do - sub_sort(0, length-1) !cmp(x,y) = cmp(x, y) - end - - # Sort `array` between `from` and `to` indices - private fun sub_sort(from: Int, to: Int) - !cmp(e1,e2: E): Int - do - if from >= to then - return - else if from + 7 < to then - var pivot = self[from] - var i = from - var j = to - while j > i do - while i <= to and cmp(self[i], pivot) <= 0 do i += 1 - while j > i and cmp(self[j], pivot) >= 0 do j -= 1 - if j > i then - var t = self[i] - self[i] = self[j] - self[j] = t - end - end - self[from] = self[i-1] - self[i-1] = pivot - sub_sort(from, i-2) !cmp(x,y) = cmp(x, y) - sub_sort(i, to) !cmp(x,y) = cmp(x, y) - else - var i = from - while i < to do - var min = i - var min_v = self[i] - var j = i - while j <= to do - if cmp(min_v, self[j]) > 0 then - min = j - min_v = self[j] - end - j += 1 - end - if min != i then - self[min] = self[i] - self[i] = min_v - end - i += 1 - end - end - end end # An `Iterator` on `AbstractArray` diff --git a/lib/standard/collection/hash_collection.nit b/lib/standard/collection/hash_collection.nit index 7da6eb2..9a53f99 100644 --- a/lib/standard/collection/hash_collection.nit +++ b/lib/standard/collection/hash_collection.nit @@ -216,16 +216,6 @@ class HashMap[K: Object, V] redef fun iterator: HashMapIterator[K, V] do return new HashMapIterator[K,V](self) - redef fun iterate - !each(k: K, v: V) - do - var c = _first_item - while c != null do - each(c._key, c._value) - c = c._next_item - end - end - redef fun length do return _length redef fun is_empty do return _length == 0 diff --git a/lib/standard/collection/range.nit b/lib/standard/collection/range.nit index 1b4d5bb..1c3e934 100644 --- a/lib/standard/collection/range.nit +++ b/lib/standard/collection/range.nit @@ -42,17 +42,6 @@ class Range[E: Discrete] redef fun iterator do return new IteratorRange[E](self) - redef fun iterate - !each(e: E) - do - var c = _first - var l = _last - while c <= l do - each(c) - c = c.succ - end - end - redef fun length do var nb = _first.distance(_after) diff --git a/lib/standard/kernel.nit b/lib/standard/kernel.nit index 3cf33ba..bf158a3 100644 --- a/lib/standard/kernel.nit +++ b/lib/standard/kernel.nit @@ -400,28 +400,6 @@ universal Int end end - # Execute 'each' for each integer in [self..last] - fun enumerate_to(last: Int) - !each(i: Int) - do - var cur = self - while cur <= last do - each(cur) - cur += 1 - end - end - - # Execute 'each' for each integer in [self..after[ - fun enumerate_before(after: Int) - !each(i: Int) - do - var cur = self - while cur < after do - each(cur) - cur += 1 - end - end - # The absolute value of self # # assert (-10).abs == 10 diff --git a/tests/base_closure1.nit b/tests/base_closure1.nit deleted file mode 100644 index 53a8fb7..0000000 --- a/tests/base_closure1.nit +++ /dev/null @@ -1,57 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - !bar - do - 1.output - bar #alt1# - #alt2#bar(2) - #alt3#var x = bar - 4.output - end -end - -fun maybe: Bool do return true - -fun work -do - var a = new A - a.foo !bar do #alt11# - #alt11#a.foo !bar x do - 2.output - if maybe then - #alt4#break - #alt5#break 'x' - #alt6#continue - #alt7#continue 'x' - #alt8#return - #alt9#return 'x' - end - 3.output - end - #alt10# a.foo - #alt12# a.foo !baz do (-1).output - 5.output -end - -0.output -work -6.output - diff --git a/tests/base_closure10.nit b/tests/base_closure10.nit deleted file mode 100644 index 5517fa1..0000000 --- a/tests/base_closure10.nit +++ /dev/null @@ -1,55 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo !k -do - ' '.output - '<'.output - 1.output - k - ' '.output - '>'.output - 1.output -end - -fun test -do - '<'.output - 0.output - var i = 0 - while i < 3 do - foo !k do - ' '.output - ' '.output - '<'.output - 2.output - if i == 1 then - break - end - ' '.output - ' '.output - '>'.output - 2.output - end - i += 1 - end - '>'.output - 0.output -end - -test diff --git a/tests/base_closure11.nit b/tests/base_closure11.nit deleted file mode 100644 index 028fbc7..0000000 --- a/tests/base_closure11.nit +++ /dev/null @@ -1,60 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo - !x -do - 'F'.output - 0.output - bar !y do - 'F'.output - 1.output - x - 'F'.output - 1.output - end - 'F'.output - 0.output -end - -fun bar - !y -do - 'B'.output - 0.output - y - 'B'.output - 0.output -end - -'M'.output -0.output -foo !x do - 'M'.output - 1.output - foo !x do - 'M'.output - 2.output - #alt1#break - #alt2#return - end - 'M'.output - 1.output -end -'M'.output -0.output diff --git a/tests/base_closure2.nit b/tests/base_closure2.nit deleted file mode 100644 index 821d2ad..0000000 --- a/tests/base_closure2.nit +++ /dev/null @@ -1,57 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - !bar(i: Int) - do - 1.output - bar(2) #alt1# - #alt2#bar - #alt12#bar('x') - #alt3#var x = bar(2) - 4.output - end -end - -fun maybe: Bool do return true - -fun work -do - var a = new A - a.foo !bar x do #alt11# - #alt11#a.foo !bar do - x.output - if maybe then - #alt4#break - #alt5#break 'x' - #alt6#continue - #alt7#continue 'x' - #alt8#return - #alt9#return 'x' - end - (x+1).output - end - #alt10# a.foo - 5.output -end - -0.output -work -6.output - diff --git a/tests/base_closure3.nit b/tests/base_closure3.nit deleted file mode 100644 index 05ecc2a..0000000 --- a/tests/base_closure3.nit +++ /dev/null @@ -1,51 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo(i, j: Int) - !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 - -fun maybe: Bool do return true - -var a = new A -0.output -a.foo(1,8) !bar x, y, b do #alt2# -#alt2#a.foo(1,8) !bar x, y do - x.output - b.foo(x+1, y-1) !bar z, t, c do - z.output - if maybe then - #alt4#break - #alt5#break 'x' - #alt6#continue - #alt7#continue 'x' - #alt8#return - #alt9#return 'x' - end - t.output - end - y.output -end -9.output diff --git a/tests/base_closure4.nit b/tests/base_closure4.nit deleted file mode 100644 index 37ed4a3..0000000 --- a/tests/base_closure4.nit +++ /dev/null @@ -1,56 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - !bar: Int - do - 1.output - bar.output #alt1# - #alt2#bar(2) - #alt3#var x: Char = bar - 4.output - end -end - -fun maybe: Bool do return true - -fun work -do - var a = new A - a.foo !bar do #alt11# - #alt11#a.foo !bar x do - 2.output - if maybe then - #alt4#break - #alt5#break 'x' - #alt6#continue - #alt7#continue 'x' - #alt8#return - #alt9#return 'x' - end - continue 3 - end - #alt10# a.foo - 5.output -end - -0.output -work -6.output - diff --git a/tests/base_closure5.nit b/tests/base_closure5.nit deleted file mode 100644 index 71a204b..0000000 --- a/tests/base_closure5.nit +++ /dev/null @@ -1,56 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo: Int - !bar: Int - do - 1.output - var r = bar - 3.output - return r - end -end - -fun maybe: Bool do return true - -fun work: Int -do - var a = new A - var i = a.foo !bar do - 2.output - if maybe then - #alt1#break - #alt2#break 'x' - #alt3#break 100 - #alt4#return - #alt5#return 'x' - #alt6#return 200 - #alt7#continue - #alt8#continue 'x' - end - continue 5 #alt9# - end - 4.output - return i -end - -0.output -work.output -6.output - diff --git a/tests/base_closure6.nit b/tests/base_closure6.nit deleted file mode 100644 index 5d26989..0000000 --- a/tests/base_closure6.nit +++ /dev/null @@ -1,78 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo: U - !bar - do - return new U - end -end - -class T -end - -class U - super T -end - -class V - super T -end - -class W - super U - super V -end - -fun maybe: Bool do return true - -var a = new A - -var t: T = new T -var u: U = new U -var v: V = new V -var w: W = new W - -var y: Object#alt1# -#alt1#var y: U -y = a.foo !bar do 0.output -y = a.foo !bar do break t -y = a.foo !bar do break u -y = a.foo !bar do break v -y = a.foo !bar do break w -y = a.foo !bar do - if maybe then - break t - else if maybe then - break u - else if maybe then - break v - else if maybe then - break w - end -end -y = a.foo !bar do - if maybe then - break u - else if maybe then - break v - else if maybe then - break w - end -end diff --git a/tests/base_closure7.nit b/tests/base_closure7.nit deleted file mode 100644 index 8718d19..0000000 --- a/tests/base_closure7.nit +++ /dev/null @@ -1,46 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun repeat(x: Int) - !each(i: Int) -do - var c = 0 - while c < x do - each(c) - c += 1 - end -end - -fun work -do - repeat(4) !each i do - i.output - repeat(4) !each 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 - diff --git a/tests/base_closure8.nit b/tests/base_closure8.nit deleted file mode 100644 index ad72510..0000000 --- a/tests/base_closure8.nit +++ /dev/null @@ -1,58 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo(i: Int) - !bar - do - '['.output - i.output - bar !break do - '!'.output - i.output - end - #alt4#bar !baz do abort - ']'.output - i.output - end -end - -fun maybe: Bool do return true - -fun start -do - var a = new A - 0.output - a.foo(1) !bar do - 2.output - a.foo(3) !bar do - 4.output - if maybe then - #alt1#break - #alt2#continue - #alt3#return - end - 5.output - end - 6.output - end - 7.output -end - -start -8.output diff --git a/tests/base_closure9.nit b/tests/base_closure9.nit deleted file mode 100644 index 5b34790..0000000 --- a/tests/base_closure9.nit +++ /dev/null @@ -1,74 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun 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 - - fun foo(i: Int, j: Char) - !bar - do - if i >= 3 then - indent(i, j, '{') - bar - indent(i, j, '}') - return - end - - indent(i, j, '[') - foo(i+1, 'a') !bar do - foo(i+1, 'b') !bar do - foo(i+1, 'c') !bar do - indent(i, j, '<') - bar - indent(i, j, '>') - end - end - end - indent(i, j, ']') - end -end - -fun start -do - var a = new A - 0.output - a.foo(0, 'A') !bar do - a.foo(0, 'B') !bar do - a.foo(0, 'C') !bar do - 1.output - #alt1# break - #alt2# return - end - end - end - 2.output -end - -start -3.output diff --git a/tests/base_closure_break.nit b/tests/base_closure_break.nit deleted file mode 100644 index e4934fb..0000000 --- a/tests/base_closure_break.nit +++ /dev/null @@ -1,58 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - break !bar #alt12# - #alt12#break !bar: Int - do - 1.output - if maybe then bar #alt1# - #alt2#if maybe then bar(2) - #alt3#if maybe then var x = bar - 4.output - end -end - -fun maybe: Bool do return true - -fun work -do - var a = new A - a.foo !bar do #alt11# - #alt11#a.foo !bar x do - 2.output - if maybe then - #alt4#break - #alt5#break 'x' - #alt6#continue - #alt7#continue 'x' - #alt8#return - #alt9#return 'x' - end - 3.output - break #alt13# - end - #alt10# a.foo - 5.output -end - -0.output -work -6.output - diff --git a/tests/base_closure_break2.nit b/tests/base_closure_break2.nit deleted file mode 100644 index 8902df3..0000000 --- a/tests/base_closure_break2.nit +++ /dev/null @@ -1,59 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo: Int - break !bar #alt12# - #alt12#break !bar: Int - do - 1.output - if maybe then bar #alt1# - #alt2#if maybe then bar(2) - #alt3#if maybe then var x = bar - return 4 - end -end - -fun maybe: Bool do return true - -fun work -do - var a = new A - var r = a.foo !bar do #alt11# - #alt11#var r = a.foo !bar x do - 2.output - if maybe then - #alt4#break 4 - #alt5#break 'x' - #alt6#continue - #alt7#continue 'x' - #alt8#return - #alt9#return 'x' - end - 3.output - break 4 #alt13# - end - r.output - #alt10# a.foo - 5.output -end - -0.output -work -6.output - diff --git a/tests/base_closure_break_default.nit b/tests/base_closure_break_default.nit deleted file mode 100644 index a0f324d..0000000 --- a/tests/base_closure_break_default.nit +++ /dev/null @@ -1,47 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - break !bar do - if maybe then - #alt1# return - #alt2# return 1 - #alt3# abort - #alt4# continue - #alt5# continue 20 - #alt6# break - #alt7# break 1 - end - 20.output - end - do - 1.output - if maybe then bar - 3.output - end -end - -fun maybe: Bool do return true - -var a = new A -0.output -a.foo !bar do 2.output -0.output -a.foo -0.output diff --git a/tests/base_closure_break_default2.nit b/tests/base_closure_break_default2.nit deleted file mode 100644 index 9fdb3ad..0000000 --- a/tests/base_closure_break_default2.nit +++ /dev/null @@ -1,51 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo: Int - break !bar do - if maybe then - #alt1# return - #alt2# return 1 - #alt3# abort - #alt4# continue - #alt5# continue 20 - #alt6# break - #alt7# break 1 - #alt8# break 'x' - end - break 20#alt9# - end - do - 1.output - if maybe then bar - 3.output - return 3 - end -end - -fun maybe: Bool do return true - -var a = new A -0.output -var x = a.foo !bar do break 2 -x.output -0.output -x = a.foo -x.output -0.output diff --git a/tests/base_closure_continue_assign.nit b/tests/base_closure_continue_assign.nit deleted file mode 100644 index 8d7b74a..0000000 --- a/tests/base_closure_continue_assign.nit +++ /dev/null @@ -1,47 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo - !f: Int -do - f.output -end - -fun bar - !f(i: Int): Int -do - f(1).output -end - -fun baz - !f do end - !g: Int = 3 -do - f - g.output -end - -foo !f = 1 -bar !f(i) = i + 1 -baz -baz !f do - 4.output -!g = 5 -#alt1#foo !f = 'a' -#alt2#baz !f = 3 -#alt3#baz !g = 6 diff --git a/tests/base_closure_default1.nit b/tests/base_closure_default1.nit deleted file mode 100644 index ffe3698..0000000 --- a/tests/base_closure_default1.nit +++ /dev/null @@ -1,47 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - !bar do - if maybe then - #alt1# return - #alt2# return 1 - #alt3# abort - #alt4# continue - #alt5# continue 20 - #alt6# break - #alt7# break 1 - end - 20.output - end - do - 1.output - bar - 3.output - end -end - -fun maybe: Bool do return true - -var a = new A -0.output -a.foo !bar do 2.output -0.output -a.foo -0.output diff --git a/tests/base_closure_default2.nit b/tests/base_closure_default2.nit deleted file mode 100644 index dd43e5d..0000000 --- a/tests/base_closure_default2.nit +++ /dev/null @@ -1,48 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - !bar(i: Int) do - if maybe then - #alt1# return - #alt2# return 1 - #alt3# abort - #alt4# continue - #alt5# continue 20 - #alt7# break - #alt8# break 1 - end - (i * 10).output - end - do - 1.output - bar(2) - #alt6#i.output - 3.output - end -end - -fun maybe: Bool do return true - -var a = new A -0.output -a.foo !bar j do j.output -0.output -a.foo -0.output diff --git a/tests/base_closure_default3.nit b/tests/base_closure_default3.nit deleted file mode 100644 index 4cab9a2..0000000 --- a/tests/base_closure_default3.nit +++ /dev/null @@ -1,46 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - !bar: Int do - if maybe then - #alt1# return - #alt2# return 1 - #alt3# abort - #alt4# continue - #alt6# break 1 - end - #alt5# break - continue 20 #alt5# - end - do - 1.output - bar.output - 3.output - end -end - -fun maybe: Bool do return true - -var a = new A -0.output -a.foo !bar do continue 2 -0.output -a.foo -0.output diff --git a/tests/base_closure_default4.nit b/tests/base_closure_default4.nit deleted file mode 100644 index 561f298..0000000 --- a/tests/base_closure_default4.nit +++ /dev/null @@ -1,46 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - fun foo - !bar(i: Int): Int do - if maybe then - #alt1# return - #alt2# return -1 - #alt3# abort - #alt4# continue - #alt6# break - #alt7# break 1 - end - continue i * 10 #alt5# - end - do - 1.output - bar(2).output - 3.output - end -end - -fun maybe: Bool do return true - -var a = new A -0.output -a.foo !bar j do continue j -0.output -a.foo -0.output diff --git a/tests/base_closure_forms.nit b/tests/base_closure_forms.nit deleted file mode 100644 index 262d433..0000000 --- a/tests/base_closure_forms.nit +++ /dev/null @@ -1,233 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2006-2008 Jean Privat -# -# 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 Array[E] - fun sort - !cmp(a, b: E): Int - do - var e1 = _e1 - var e2 = _e2 - if cmp(e1, e2) > 0 then - _e1 = e2 - _e2 = e1 - end - end - - fun iterate - !each(e: E) - do - each(_e1) - each(_e2) - end - - var _e1: E - var _e2: E - - init(e1, e2: E) - do - _e1 = e1 - _e2 = e2 - end - - redef fun output - do - '['.output - _e1.output - ','.output - _e2.output - ']'.output - '\n'.output - end -end - -class Map[K, V] - fun [](k: K): V - !def: V do abort - do - if _k == k then return _v - var n = _next - if n != null then return n[k] !def do continue def - var v = def - _next = new Map[K, V](k, v) - return v - end - fun has_key(k: K): Bool - do - if _k == k then return true - var n = _next - if n != null then return n.has_key(k) else return false - end - fun iterate - !each2(k: K, v: V) - do - var n: nullable Map[K, V] = self - while n != null do - each2(n._k, n._v) - n = n._next - end - end - var _k: K - var _v: V - var _next: nullable Map[K, V] - init(k: K, v: V) - do - _k = k - _v = v - end - redef fun output - do - '{'.output - output_inner - '}'.output - '\n'.output - end - fun output_inner - do - _k.output - ':'.output - _v.output - var n = _next - if n != null then - ','.output - n.output_inner - end - end -end - -class File - readable var _id: Int - readable var _is_open: Bool - fun close - do - if _is_open then - 'C'.output - _id.output - _is_open = false - end - end - init(id: Int) - do - _id = id - _is_open = id > 0 - end -end - -fun file_open(i: Int) - !work(f: File) - break !error(j: Int) do abort -do - var f = new File(i) - if not f.is_open then error(404) - work(f) !break do f.close - f.close -end - -################## - -fun test_sort -do - var a = new Array[Char]('2', '1') - a.output - a.sort !cmp(x, y) = x <=> y - a.output - a.sort !cmp(x, y) = y <=> x - a.output - a.iterate !each i do i.output - '\n'.output -end - -fun test_map -do - var m = new Map[Char, Char]('I', '1') - - m.output - - if not m.has_key('I') then (-1).output - 'I'.output - '='.output - var i = m['I'] - i.output - '\n'.output - - m.output - - if m.has_key('V') then (-2).output - 'V'.output - '='.output - i = m['V'] !def = '5' - i.output - '\n'.output - - m.output - - if not m.has_key('V') then (-3).output - 'V'.output - '='.output - i = m['V'] !def = '6' - i.output - '\n'.output - - m.output - - if m.has_key('X') then (-4).output - 'X'.output - '='.output - i = m['X'] !def do break '0' - i.output - '\n'.output - - m.output - - if m.has_key('X') then (-5).output - - m.iterate !each2(k,v) do - k.output - '='.output - v.output - ';'.output - end - '\n'.output -end - -fun test_file(i: Int) -do - var f_escape: nullable File = null - file_open(i) !work(f) do - 'O'.output - '?'.output - f.is_open.output - f_escape = f - !error(e) do - 'E'.output - e.output - end - if f_escape != null then - 'O'.output - '?'.output - f_escape.is_open.output - end -end - -test_sort -'\n'.output -test_map -'\n'.output -test_file(1) -'\n'.output -test_file(-1) - diff --git a/tests/base_closure_multi.nit b/tests/base_closure_multi.nit deleted file mode 100644 index 01ce323..0000000 --- a/tests/base_closure_multi.nit +++ /dev/null @@ -1,76 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 -fun a - !a1 - !a2 #alt1# -#alt2# !a3 -#alt6# !a1 -do - a1 - a2 #alt1# -#alt2# a3 -end - -fun b - !b1 - !b2 -do - b1 - b2 -end - -fun c - !c1 -do - c1 -end - -fun d - !d1 - !d2 - !d3 -do - d1 - d2 - d3 -end - -0.output -a !a1 do - b !b1 do - 1.output - !b2 do #alt3# - 2.output #alt3# -#alt4# !b3 do -#alt4# 20.output - end -!a2 do - 3.output -end -4.output -c !c1 do - d !d1 do - 5.output - !d2 do - 6.output - !d3 do 7.output -end -#alt5#a !a2 do -#alt5#!a1 do -#alt5#end -8.output diff --git a/tests/base_closure_raf.nit b/tests/base_closure_raf.nit deleted file mode 100644 index 15bd66b..0000000 --- a/tests/base_closure_raf.nit +++ /dev/null @@ -1,59 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 base_closure2 - -class B - super A - redef fun foo - !bar(i: Int) #alt13# #alt14# #alt15# - #alt13# !bar - #alt14# !bar(b: Bool) - #alt15# !bar(i: Int): Int - do - 10.output - bar(20) #alt1# - #alt2#bar - #alt12#bar('x') - #alt3#var x = bar(2) - 40.output - end -end - -fun work2 -do - var a: A = new B - a.foo !bar x do #alt11# - #alt11#a.foo !bar do - x.output - if maybe then - #alt4#break - #alt5#break 'x' - #alt6#continue - #alt7#continue 'x' - #alt8#return - #alt9#return 'x' - end - (x+1).output - end - #alt10# a.foo - 5.output -end - -0.output -work2 -6.output - diff --git a/tests/base_closure_single_return.nit b/tests/base_closure_single_return.nit deleted file mode 100644 index b451b34..0000000 --- a/tests/base_closure_single_return.nit +++ /dev/null @@ -1,35 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo - !f -do - f -end - -fun test: Int -do - var i = 1 - i.output - foo !f do - return 2 - end - abort -end - -test.output diff --git a/tests/base_for_custom.nit b/tests/base_for_custom.nit deleted file mode 100644 index 83c238a..0000000 --- a/tests/base_for_custom.nit +++ /dev/null @@ -1,48 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.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 - var v: Int - fun iterate #alt1# - #alt1# fun foo - !each(i: Int) #alt2# #alt5# - #alt5#!each(i: Int): Int - do - each(v) - end -end - -class B - var v: Int - fun iterate - !each(i: Int, j: Bool) - do - each(v, v != 0) - end -end - -var a = new A(5) -for i in a do #alt3# -#alt3#for i, j in a do - i.output -end - -var b = new B(5) -for i, j in b do #alt4# -#alt4#for i in b do - i.output - j.output #alt4# -end diff --git a/tests/base_inline_closure.nit b/tests/base_inline_closure.nit deleted file mode 100644 index 0d03612..0000000 --- a/tests/base_inline_closure.nit +++ /dev/null @@ -1,44 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -interface Inline__ - fun foo - !f - do - 0.output - f - 2.output - end - - fun bar - !b do 11.output - do - 10.output - b - 12.output - end -end - -class A - super Inline__ -end - -var a: A = new A -a.foo !f do 1.output -a.bar !b do 1.output -a.bar diff --git a/tests/base_inline_closure2.nit b/tests/base_inline_closure2.nit deleted file mode 100644 index 6d64fda..0000000 --- a/tests/base_inline_closure2.nit +++ /dev/null @@ -1,44 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -interface Inline__ - fun foo - !f: Int - do - 0.output - f.output - 2.output - end - - fun bar - !b: Int do continue 11 - do - 10.output - b.output - 12.output - end -end - -class A - super Inline__ -end - -var a: A = new A -a.foo !f do continue 1 -a.bar !b do continue 1 -a.bar diff --git a/tests/base_inline_closure_escape.nit b/tests/base_inline_closure_escape.nit deleted file mode 100644 index d996d58..0000000 --- a/tests/base_inline_closure_escape.nit +++ /dev/null @@ -1,54 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2008 Jean Privat -# -# 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 Inline__ - fun foo1 - !f - do - f - 5.output - end - - fun foo2 - !f - do - f - 2.output - end -end - -fun maybe: Bool do return true - -var a = new Inline__ -a.foo1 !f do - do - a.foo2 !f do - if maybe then - #alt1#break label l1 - #alt2#break label l2 - #alt3#break label l3 - #alt4#continue label l1 - #alt5#continue label l2 - end - 1.output - end label l1 - 3.output - end label l3 - 4.output -end label l2 -6.output diff --git a/tests/base_inline_closure_escape2.nit b/tests/base_inline_closure_escape2.nit deleted file mode 100644 index ecf1ee3..0000000 --- a/tests/base_inline_closure_escape2.nit +++ /dev/null @@ -1,56 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2008 Jean Privat -# -# 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 Inline__ - fun foo1: Int - !f: Int - do - f.output - return 5 - end - - fun foo2: Int - !f: Int - do - f.output - return 2 - end -end - -fun maybe: Bool do return true - -var a = new Inline__ -var x = a.foo1 !f do - do - var y = a.foo2 !f do - if maybe then - #alt1#break label l1 20 - #alt2#break label l2 50 - #alt3#break label l3 - #alt4#continue label l1 10 - #alt5#continue label l2 40 - end - continue 1 - end label l1 - y.output - 3.output - end label l3 - continue 4 -end label l2 -x.output -6.output diff --git a/tests/base_inline_closure_escape3.nit b/tests/base_inline_closure_escape3.nit deleted file mode 100644 index d441fe3..0000000 --- a/tests/base_inline_closure_escape3.nit +++ /dev/null @@ -1,53 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2008 Jean Privat -# -# 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 Inline__ - fun foo - !f - do - do - if true then - f - break label l0 - end - 0.output - end label l0 - 5.output - end -end - -fun maybe: Bool do return true - -var a = new Inline__ -a.foo !f do - do - a.foo !f do - if maybe then - #alt1#break label l1 - #alt2#break label l2 - #alt3#break label l3 - #alt4#continue label l1 - #alt5#continue label l2 - end - 1.output - end label l1 - 3.output - end label l3 - 4.output -end label l2 -6.output diff --git a/tests/base_inline_closure_fork.nit b/tests/base_inline_closure_fork.nit deleted file mode 100644 index 3a2f6df..0000000 --- a/tests/base_inline_closure_fork.nit +++ /dev/null @@ -1,56 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2008 Jean Privat -# -# 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 Inline__ - fun foo1 - !f - do - f - f - end - fun foo2 - !f - do - f - f - end -end - -class B - var _b: Int - redef fun output do _b.output -end - -var a = new Inline__ -a.foo1 !f do - var x = new B(1) - var y = 2 - a.foo2 !f do - x.output - y.output - x = new B(3) - y = 4 - #alt1#break label l1 - #alt2#break label l2 - #alt3#continue label l1 - #alt4#continue label l2 - end label l1 - x.output - y.output -end label l2 -5.output diff --git a/tests/base_inline_closure_fork2.nit b/tests/base_inline_closure_fork2.nit deleted file mode 100644 index f6a4f6e..0000000 --- a/tests/base_inline_closure_fork2.nit +++ /dev/null @@ -1,54 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2008 Jean Privat -# -# 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 Inline__ - fun foo - !f - do - f - f - end -end - -class B - var _b: Int - redef fun output do _b.output -end - -fun maybe: Bool do return true - -var a = new Inline__ -a.foo !f do - var x = new B(1) - var y = 2 - a.foo !f do - x.output - y.output - x = new B(3) - y = 4 - if maybe then - #alt1#break label l1 - #alt2#break label l2 - #alt3#continue label l1 - #alt4#continue label l2 - end - end label l1 - x.output - y.output -end label l2 -5.output diff --git a/tests/base_inline_closure_nested.nit b/tests/base_inline_closure_nested.nit deleted file mode 100644 index b6778dc..0000000 --- a/tests/base_inline_closure_nested.nit +++ /dev/null @@ -1,64 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -interface Inline__ - fun foo - !f - do - 0.output - f - 2.output - end - - fun bar - !b do 11.output - do - 10.output - b - 12.output - end -end - -class A - super Inline__ -end - -fun test1 -do - var a: A = new A - 5.output - a.bar !b do - 15.output - a.bar - end -end - -fun test2 -do - var a: A = new A - a.foo !f do - 5.output - a.bar !b do - 15.output - a.bar - end - end -end - -test1 -test2 diff --git a/tests/base_inline_closurecall.nit b/tests/base_inline_closurecall.nit deleted file mode 100644 index 9f4e64c..0000000 --- a/tests/base_inline_closurecall.nit +++ /dev/null @@ -1,65 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 Inline__ - fun foo - !f - do - 0.output - f - 2.output - end - - fun bar - !b do 11.output - do - 10.output - b - 12.output - end -end - -class A - fun baz - !b - do - var inl = new Inline__ - inl.foo !f do b - inl.bar !b do b - inl.bar - inl.foo !f do inl.bar !b do b - end - - fun baz2 - !b do 22.output - do - var inl = new Inline__ - inl.foo !f do b - inl.bar !b do b - inl.bar - inl.foo !f do inl.bar !b do b - end -end - - -var a = new A -a.baz !b do 20.output -'\n'.output -a.baz2 !b do 21.output -'\n'.output -a.baz2 diff --git a/tests/base_iterate_range.nit b/tests/base_iterate_range.nit deleted file mode 100644 index 5d9a8c2..0000000 --- a/tests/base_iterate_range.nit +++ /dev/null @@ -1,22 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 range - -for i in [0..4] do i.output -for i in [0..5[ do i.output -0.enumerate_to(4) !each (i) do i.output -0.enumerate_before(5) !each (i) do i.output diff --git a/tests/base_label_closure.nit b/tests/base_label_closure.nit deleted file mode 100644 index dc8e161..0000000 --- a/tests/base_label_closure.nit +++ /dev/null @@ -1,48 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo - !bar -do - bar !break do 'X'.output -end - -fun maybe: Bool do return true - -1.output -foo !bar do - 2.output - foo !bar do - 3.output - foo !bar do end label l3 - if maybe then - #alt1#break label l2 - #alt2#break label l3 - #alt3#break label l4 - #alt4#break - #alt5#continue label l1 - end - if maybe then break label l1 - 4.output - end label l2#alt6# - #alt6#end label l1 - 5.output -end label l1 -6.output - -#alt7#foo !bar do end label l1 diff --git a/tests/base_label_closure2.nit b/tests/base_label_closure2.nit deleted file mode 100644 index d7f608c..0000000 --- a/tests/base_label_closure2.nit +++ /dev/null @@ -1,57 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo: Int - !bar: Int -do - var i = bar !break do 'X'.output - return i * 10 -end - -fun maybe: Bool do return true - -1.output -var i = foo !bar do - 2.output - var j = foo !bar do - 3.output - foo !bar do - continue 0 - end label l3 - if maybe then - #alt1#break label l2 10 - #alt2#break label l3 10 - #alt3#break label l4 10 - #alt4#break 10 - #alt5#continue label l1 10 - end - if maybe then break label l1 10 - 4.output - break 4 - end label l2#alt6# - #alt6#end label l1 - j.output - 5.output - continue 20 -end label l1 -i.output -6.output - -#alt7#foo !bar do -#alt7# continue 0 -#alt7#end label l1 diff --git a/tests/base_label_closure3.nit b/tests/base_label_closure3.nit deleted file mode 100644 index d0eb8ba..0000000 --- a/tests/base_label_closure3.nit +++ /dev/null @@ -1,54 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo - !bar do end - !baz do end -do - bar - baz -end - -fun maybe: Bool do return true - -1.output -foo !bar do - 2.output - foo !bar do - 3.output - foo !bar do end label l3 - if maybe then - #alt1#break label l2 - #alt2#break label l3 - #alt3#break label l4 - #alt4#break - #alt5#continue label l1 - end - if maybe then break label l1 - 4.output - !baz do - 40.output - end label l2#alt6# - #alt6#end label l1 - 5.output -!baz do - 50.output -end label l1 -6.output - -#alt7#foo !bar do end label l1 diff --git a/tests/base_var_closure.nit b/tests/base_var_closure.nit deleted file mode 100644 index a075d7f..0000000 --- a/tests/base_var_closure.nit +++ /dev/null @@ -1,41 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 - -fun foo(p1: Int) - !bar(p2: Int) do (p1+p2).output - #alt1#!bar(p2: Int) do (p1*p2).output - #alt2#!p1 do abort -do - bar(p1*10) - #alt3#var bar: Int = p1 - #alt4#p2.output -end - -foo(0) -var a1: Int = 1 -foo(2) !bar(a2) do - #alt5#var a1: Int = 3 - #alt6#var a2: Int = 3 - #alt7#foo(3) !bar(a1) do a1.output - #alt8#foo(4) !bar(a2) do a1.output - a1.output - a2.output -end -var a2: Int = 5 -a1.output -a2.output diff --git a/tests/bench_int_range_closure.nit b/tests/bench_int_range_closure.nit deleted file mode 100644 index 8f06236..0000000 --- a/tests/bench_int_range_closure.nit +++ /dev/null @@ -1,45 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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] - fun for_each(x: Int) - !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) !each ii1 do - r.for_each(1) !each ii2 do - r.for_each(2) !each ii3 do - if ii1 == ii2 and ii2 == ii3 then cpt += 1 - end - end -end - -print cpt diff --git a/tests/example_array_sort.nit b/tests/example_array_sort.nit deleted file mode 100644 index 028e584..0000000 --- a/tests/example_array_sort.nit +++ /dev/null @@ -1,38 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2005-2009 Jean Privat -# -# 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. - -fun get_an_array(nb: Int): Array[Int] -do - var res = new Array[Int].with_capacity(nb) - var j = 64 - while res.length < nb do - j = (j * 3451 + 234) % 56557 - var k = j % 90 + 10 - res.add(k) - end - return res -end - -var q = get_an_array(50) -print(q.join(" ")) -q.sort !cmp(x,y) = x <=> y -print(q.join(" ")) -q.sort !cmp(x,y) = (x%10) <=> (y%10) -print(q.join(" ")) -q.sort !cmp(x,y) = y <=> x -print(q.join(" ")) -q.sort !cmp(x,y) = (x%10) <=> (y%10) -print(q.join(" ")) diff --git a/tests/example_power_with_iterate.nit b/tests/example_power_with_iterate.nit deleted file mode 100644 index aa31971..0000000 --- a/tests/example_power_with_iterate.nit +++ /dev/null @@ -1,31 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.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. - -class Power - var number: Int - var exponent: Int - - fun iterate !each(i: Int) - do - var res = 1 - for i in [0..self.exponent[ do - res = res * self.number - each(res) - end - end -end - -for i in new Power(2, 8) do - print i -end diff --git a/tests/sav/base_closure1.res b/tests/sav/base_closure1.res deleted file mode 100644 index 09c277a..0000000 --- a/tests/sav/base_closure1.res +++ /dev/null @@ -1,7 +0,0 @@ -0 -1 -2 -3 -4 -5 -6 diff --git a/tests/sav/base_closure10.res b/tests/sav/base_closure10.res deleted file mode 100644 index ccbea92..0000000 --- a/tests/sav/base_closure10.res +++ /dev/null @@ -1,12 +0,0 @@ -<0 - <1 - <2 - >2 - >1 - <1 - <2 - <1 - <2 - >2 - >1 ->0 diff --git a/tests/sav/base_closure11.res b/tests/sav/base_closure11.res deleted file mode 100644 index fef004f..0000000 --- a/tests/sav/base_closure11.res +++ /dev/null @@ -1,17 +0,0 @@ -M0 -F0 -B0 -F1 -M1 -F0 -B0 -F1 -M2 -F1 -B0 -F0 -M1 -F1 -B0 -F0 -M0 diff --git a/tests/sav/base_closure11_alt1.res b/tests/sav/base_closure11_alt1.res deleted file mode 100644 index 853a6af..0000000 --- a/tests/sav/base_closure11_alt1.res +++ /dev/null @@ -1,14 +0,0 @@ -M0 -F0 -B0 -F1 -M1 -F0 -B0 -F1 -M2 -M1 -F1 -B0 -F0 -M0 diff --git a/tests/sav/base_closure11_alt2.res b/tests/sav/base_closure11_alt2.res deleted file mode 100644 index 49cfa3d..0000000 --- a/tests/sav/base_closure11_alt2.res +++ /dev/null @@ -1,9 +0,0 @@ -M0 -F0 -B0 -F1 -M1 -F0 -B0 -F1 -M2 diff --git a/tests/sav/base_closure1_alt1.res b/tests/sav/base_closure1_alt1.res deleted file mode 100644 index 5ac6b87..0000000 --- a/tests/sav/base_closure1_alt1.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -4 -5 -6 diff --git a/tests/sav/base_closure1_alt10.res b/tests/sav/base_closure1_alt10.res deleted file mode 100644 index 3cc6bf2..0000000 --- a/tests/sav/base_closure1_alt10.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt10.nit:49,2--6: Error: foo requires 1 blocks. diff --git a/tests/sav/base_closure1_alt11.res b/tests/sav/base_closure1_alt11.res deleted file mode 100644 index b53c672..0000000 --- a/tests/sav/base_closure1_alt11.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt11.nit:37,9--11: Error: 0 automatic variable names expected, 1 found. diff --git a/tests/sav/base_closure1_alt12.res b/tests/sav/base_closure1_alt12.res deleted file mode 100644 index 4c14251..0000000 --- a/tests/sav/base_closure1_alt12.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt12.nit:50,9--11: Error: no closure named '!baz' in foo; only closure is !bar. diff --git a/tests/sav/base_closure1_alt2.res b/tests/sav/base_closure1_alt2.res deleted file mode 100644 index a96064e..0000000 --- a/tests/sav/base_closure1_alt2.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt2.nit:25,3--8: Error: arity mismatch; prototype is 'bar'. diff --git a/tests/sav/base_closure1_alt3.res b/tests/sav/base_closure1_alt3.res deleted file mode 100644 index c781e3b..0000000 --- a/tests/sav/base_closure1_alt3.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt3.nit:26,11--13: Type error: expected expression. diff --git a/tests/sav/base_closure1_alt4.res b/tests/sav/base_closure1_alt4.res deleted file mode 100644 index fb8d875..0000000 --- a/tests/sav/base_closure1_alt4.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -2 -5 -6 diff --git a/tests/sav/base_closure1_alt5.res b/tests/sav/base_closure1_alt5.res deleted file mode 100644 index a746bcf..0000000 --- a/tests/sav/base_closure1_alt5.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt5.nit:41,3--11: Error: break without value required in this block. diff --git a/tests/sav/base_closure1_alt6.res b/tests/sav/base_closure1_alt6.res deleted file mode 100644 index 8f824a6..0000000 --- a/tests/sav/base_closure1_alt6.res +++ /dev/null @@ -1,6 +0,0 @@ -0 -1 -2 -4 -5 -6 diff --git a/tests/sav/base_closure1_alt7.res b/tests/sav/base_closure1_alt7.res deleted file mode 100644 index 6978677..0000000 --- a/tests/sav/base_closure1_alt7.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt7.nit:43,3--14: Error: continue without value required in this block. diff --git a/tests/sav/base_closure1_alt8.res b/tests/sav/base_closure1_alt8.res deleted file mode 100644 index f9c3b7b..0000000 --- a/tests/sav/base_closure1_alt8.res +++ /dev/null @@ -1,4 +0,0 @@ -0 -1 -2 -6 diff --git a/tests/sav/base_closure1_alt9.res b/tests/sav/base_closure1_alt9.res deleted file mode 100644 index cbe3605..0000000 --- a/tests/sav/base_closure1_alt9.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure1_alt9.nit:45,3--12: Error: Return with value in a procedure. diff --git a/tests/sav/base_closure2.res b/tests/sav/base_closure2.res deleted file mode 100644 index 09c277a..0000000 --- a/tests/sav/base_closure2.res +++ /dev/null @@ -1,7 +0,0 @@ -0 -1 -2 -3 -4 -5 -6 diff --git a/tests/sav/base_closure2_alt1.res b/tests/sav/base_closure2_alt1.res deleted file mode 100644 index 5ac6b87..0000000 --- a/tests/sav/base_closure2_alt1.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -4 -5 -6 diff --git a/tests/sav/base_closure2_alt10.res b/tests/sav/base_closure2_alt10.res deleted file mode 100644 index 2a52b98..0000000 --- a/tests/sav/base_closure2_alt10.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt10.nit:50,2--6: Error: foo requires 1 blocks. diff --git a/tests/sav/base_closure2_alt11.res b/tests/sav/base_closure2_alt11.res deleted file mode 100644 index aa00b67..0000000 --- a/tests/sav/base_closure2_alt11.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt11.nit:38,9--11: Error: 1 automatic variable names expected, 0 found. diff --git a/tests/sav/base_closure2_alt12.res b/tests/sav/base_closure2_alt12.res deleted file mode 100644 index ee02702..0000000 --- a/tests/sav/base_closure2_alt12.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt12.nit:26,7--9: Type error: expected Int, got Char diff --git a/tests/sav/base_closure2_alt2.res b/tests/sav/base_closure2_alt2.res deleted file mode 100644 index 8062d4a..0000000 --- a/tests/sav/base_closure2_alt2.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt2.nit:25,3--5: Error: arity mismatch; prototype is 'bar(i: Int)'. diff --git a/tests/sav/base_closure2_alt3.res b/tests/sav/base_closure2_alt3.res deleted file mode 100644 index 6124b95..0000000 --- a/tests/sav/base_closure2_alt3.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt3.nit:27,11--16: Type error: expected expression. diff --git a/tests/sav/base_closure2_alt4.res b/tests/sav/base_closure2_alt4.res deleted file mode 100644 index fb8d875..0000000 --- a/tests/sav/base_closure2_alt4.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -2 -5 -6 diff --git a/tests/sav/base_closure2_alt5.res b/tests/sav/base_closure2_alt5.res deleted file mode 100644 index c8a3f39..0000000 --- a/tests/sav/base_closure2_alt5.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt5.nit:42,3--11: Error: break without value required in this block. diff --git a/tests/sav/base_closure2_alt6.res b/tests/sav/base_closure2_alt6.res deleted file mode 100644 index 8f824a6..0000000 --- a/tests/sav/base_closure2_alt6.res +++ /dev/null @@ -1,6 +0,0 @@ -0 -1 -2 -4 -5 -6 diff --git a/tests/sav/base_closure2_alt7.res b/tests/sav/base_closure2_alt7.res deleted file mode 100644 index cd6b1f3..0000000 --- a/tests/sav/base_closure2_alt7.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt7.nit:44,3--14: Error: continue without value required in this block. diff --git a/tests/sav/base_closure2_alt8.res b/tests/sav/base_closure2_alt8.res deleted file mode 100644 index f9c3b7b..0000000 --- a/tests/sav/base_closure2_alt8.res +++ /dev/null @@ -1,4 +0,0 @@ -0 -1 -2 -6 diff --git a/tests/sav/base_closure2_alt9.res b/tests/sav/base_closure2_alt9.res deleted file mode 100644 index 66fea2b..0000000 --- a/tests/sav/base_closure2_alt9.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure2_alt9.nit:46,3--12: Error: Return with value in a procedure. diff --git a/tests/sav/base_closure3.res b/tests/sav/base_closure3.res deleted file mode 100644 index 8b1acc1..0000000 --- a/tests/sav/base_closure3.res +++ /dev/null @@ -1,10 +0,0 @@ -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 diff --git a/tests/sav/base_closure3_alt1.res b/tests/sav/base_closure3_alt1.res deleted file mode 100644 index e7a911c..0000000 --- a/tests/sav/base_closure3_alt1.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure3_alt1.nit:25,3--15: Error: arity mismatch; prototype is 'bar(k: Int, l: Int, a: A)'. diff --git a/tests/sav/base_closure3_alt2.res b/tests/sav/base_closure3_alt2.res deleted file mode 100644 index dbebb68..0000000 --- a/tests/sav/base_closure3_alt2.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure3_alt2.nit:35,13--15: Error: 3 automatic variable names expected, 2 found. diff --git a/tests/sav/base_closure3_alt4.res b/tests/sav/base_closure3_alt4.res deleted file mode 100644 index dab840d..0000000 --- a/tests/sav/base_closure3_alt4.res +++ /dev/null @@ -1,8 +0,0 @@ -0 -1 -2 -3 -4 -7 -8 -9 diff --git a/tests/sav/base_closure3_alt5.res b/tests/sav/base_closure3_alt5.res deleted file mode 100644 index e63c04a..0000000 --- a/tests/sav/base_closure3_alt5.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure3_alt5.nit:41,3--11: Error: break without value required in this block. diff --git a/tests/sav/base_closure3_alt6.res b/tests/sav/base_closure3_alt6.res deleted file mode 100644 index 60f2ab9..0000000 --- a/tests/sav/base_closure3_alt6.res +++ /dev/null @@ -1,9 +0,0 @@ -0 -1 -2 -3 -4 -6 -7 -8 -9 diff --git a/tests/sav/base_closure3_alt7.res b/tests/sav/base_closure3_alt7.res deleted file mode 100644 index 170d367..0000000 --- a/tests/sav/base_closure3_alt7.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure3_alt7.nit:43,3--14: Error: continue without value required in this block. diff --git a/tests/sav/base_closure3_alt8.res b/tests/sav/base_closure3_alt8.res deleted file mode 100644 index 9dfcf39..0000000 --- a/tests/sav/base_closure3_alt8.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -2 -3 -4 diff --git a/tests/sav/base_closure3_alt9.res b/tests/sav/base_closure3_alt9.res deleted file mode 100644 index f57be87..0000000 --- a/tests/sav/base_closure3_alt9.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure3_alt9.nit:45,3--12: Error: Return with value in a procedure. diff --git a/tests/sav/base_closure4.res b/tests/sav/base_closure4.res deleted file mode 100644 index 09c277a..0000000 --- a/tests/sav/base_closure4.res +++ /dev/null @@ -1,7 +0,0 @@ -0 -1 -2 -3 -4 -5 -6 diff --git a/tests/sav/base_closure4_alt1.res b/tests/sav/base_closure4_alt1.res deleted file mode 100644 index 5ac6b87..0000000 --- a/tests/sav/base_closure4_alt1.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -4 -5 -6 diff --git a/tests/sav/base_closure4_alt10.res b/tests/sav/base_closure4_alt10.res deleted file mode 100644 index b51f311..0000000 --- a/tests/sav/base_closure4_alt10.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt10.nit:49,2--6: Error: foo requires 1 blocks. diff --git a/tests/sav/base_closure4_alt11.res b/tests/sav/base_closure4_alt11.res deleted file mode 100644 index 0132f9f..0000000 --- a/tests/sav/base_closure4_alt11.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt11.nit:37,9--11: Error: 0 automatic variable names expected, 1 found. diff --git a/tests/sav/base_closure4_alt2.res b/tests/sav/base_closure4_alt2.res deleted file mode 100644 index 81eab86..0000000 --- a/tests/sav/base_closure4_alt2.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt2.nit:25,3--8: Error: arity mismatch; prototype is 'bar: Int'. diff --git a/tests/sav/base_closure4_alt3.res b/tests/sav/base_closure4_alt3.res deleted file mode 100644 index a37aeee..0000000 --- a/tests/sav/base_closure4_alt3.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt3.nit:26,17--19: Type error: expected Char, got Int diff --git a/tests/sav/base_closure4_alt4.res b/tests/sav/base_closure4_alt4.res deleted file mode 100644 index fb8d875..0000000 --- a/tests/sav/base_closure4_alt4.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -2 -5 -6 diff --git a/tests/sav/base_closure4_alt5.res b/tests/sav/base_closure4_alt5.res deleted file mode 100644 index daf573c..0000000 --- a/tests/sav/base_closure4_alt5.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt5.nit:41,3--11: Error: break without value required in this block. diff --git a/tests/sav/base_closure4_alt6.res b/tests/sav/base_closure4_alt6.res deleted file mode 100644 index 576fece..0000000 --- a/tests/sav/base_closure4_alt6.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt6.nit:42,3--10: Error: continue with a value required in this block. diff --git a/tests/sav/base_closure4_alt7.res b/tests/sav/base_closure4_alt7.res deleted file mode 100644 index c5fec2c..0000000 --- a/tests/sav/base_closure4_alt7.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt7.nit:43,12--14: Type error: expected Int, got Char diff --git a/tests/sav/base_closure4_alt8.res b/tests/sav/base_closure4_alt8.res deleted file mode 100644 index f9c3b7b..0000000 --- a/tests/sav/base_closure4_alt8.res +++ /dev/null @@ -1,4 +0,0 @@ -0 -1 -2 -6 diff --git a/tests/sav/base_closure4_alt9.res b/tests/sav/base_closure4_alt9.res deleted file mode 100644 index 560ce07..0000000 --- a/tests/sav/base_closure4_alt9.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure4_alt9.nit:45,3--12: Error: Return with value in a procedure. diff --git a/tests/sav/base_closure5.res b/tests/sav/base_closure5.res deleted file mode 100644 index 09c277a..0000000 --- a/tests/sav/base_closure5.res +++ /dev/null @@ -1,7 +0,0 @@ -0 -1 -2 -3 -4 -5 -6 diff --git a/tests/sav/base_closure5_alt1.res b/tests/sav/base_closure5_alt1.res deleted file mode 100644 index 99a9231..0000000 --- a/tests/sav/base_closure5_alt1.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure5_alt1.nit:38,3--7: Error: break with a value required in this block. diff --git a/tests/sav/base_closure5_alt2.res b/tests/sav/base_closure5_alt2.res deleted file mode 100644 index 605c9ee..0000000 --- a/tests/sav/base_closure5_alt2.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure5_alt2.nit:39,9--11: Type error: no most general type. Got Char and Int. diff --git a/tests/sav/base_closure5_alt3.res b/tests/sav/base_closure5_alt3.res deleted file mode 100644 index 4997439..0000000 --- a/tests/sav/base_closure5_alt3.res +++ /dev/null @@ -1,6 +0,0 @@ -0 -1 -2 -4 -100 -6 diff --git a/tests/sav/base_closure5_alt4.res b/tests/sav/base_closure5_alt4.res deleted file mode 100644 index 4fa39ab..0000000 --- a/tests/sav/base_closure5_alt4.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure5_alt4.nit:41,3--8: Error: Return without value in a function. diff --git a/tests/sav/base_closure5_alt5.res b/tests/sav/base_closure5_alt5.res deleted file mode 100644 index 3aa9730..0000000 --- a/tests/sav/base_closure5_alt5.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure5_alt5.nit:42,10--12: Type error: expected Int, got Char diff --git a/tests/sav/base_closure5_alt6.res b/tests/sav/base_closure5_alt6.res deleted file mode 100644 index 8cc5186..0000000 --- a/tests/sav/base_closure5_alt6.res +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -2 -200 -6 diff --git a/tests/sav/base_closure5_alt7.res b/tests/sav/base_closure5_alt7.res deleted file mode 100644 index 1db3b20..0000000 --- a/tests/sav/base_closure5_alt7.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure5_alt7.nit:44,3--10: Error: continue with a value required in this block. diff --git a/tests/sav/base_closure5_alt8.res b/tests/sav/base_closure5_alt8.res deleted file mode 100644 index f7b4e9f..0000000 --- a/tests/sav/base_closure5_alt8.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure5_alt8.nit:45,12--14: Type error: expected Int, got Char diff --git a/tests/sav/base_closure5_alt9.res b/tests/sav/base_closure5_alt9.res deleted file mode 100644 index c52a8fa..0000000 --- a/tests/sav/base_closure5_alt9.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure5_alt9.nit:35,17--19: Control error: Reached end of block (a 'continue' with a value was expected). diff --git a/tests/sav/base_closure6.res b/tests/sav/base_closure6.res deleted file mode 100644 index fbf8e70..0000000 --- a/tests/sav/base_closure6.res +++ /dev/null @@ -1,2 +0,0 @@ -base_closure6.nit:57,25: Type error: no most general type. Got V and U. -base_closure6.nit:74,8: Type error: no most general type. Got V and U at 72,8. diff --git a/tests/sav/base_closure6_alt1.res b/tests/sav/base_closure6_alt1.res deleted file mode 100644 index d6b626f..0000000 --- a/tests/sav/base_closure6_alt1.res +++ /dev/null @@ -1,4 +0,0 @@ -alt/base_closure6_alt1.nit:55,5--25: Type error: expected U, got T -alt/base_closure6_alt1.nit:57,25: Type error: no most general type. Got V and U. -alt/base_closure6_alt1.nit:59,5--69,3: Type error: expected U, got T -alt/base_closure6_alt1.nit:74,8: Type error: no most general type. Got V and U at 72,8. diff --git a/tests/sav/base_closure7.res b/tests/sav/base_closure7.res deleted file mode 100644 index c32046f..0000000 --- a/tests/sav/base_closure7.res +++ /dev/null @@ -1,18 +0,0 @@ -0 - 0 - 1 - 2 - 3 -1 - 0 - 2 - 3 - -2 - 0 - 1 - -3 - 0 - 1 - 2 diff --git a/tests/sav/base_closure8.res b/tests/sav/base_closure8.res deleted file mode 100644 index 75d9528..0000000 --- a/tests/sav/base_closure8.res +++ /dev/null @@ -1,11 +0,0 @@ -0 -[1 -2 -[3 -4 -5 -]3 -6 -]1 -7 -8 diff --git a/tests/sav/base_closure8_alt1.res b/tests/sav/base_closure8_alt1.res deleted file mode 100644 index 121bfe7..0000000 --- a/tests/sav/base_closure8_alt1.res +++ /dev/null @@ -1,10 +0,0 @@ -0 -[1 -2 -[3 -4 -!3 -6 -]1 -7 -8 diff --git a/tests/sav/base_closure8_alt2.res b/tests/sav/base_closure8_alt2.res deleted file mode 100644 index b57cfdd..0000000 --- a/tests/sav/base_closure8_alt2.res +++ /dev/null @@ -1,10 +0,0 @@ -0 -[1 -2 -[3 -4 -]3 -6 -]1 -7 -8 diff --git a/tests/sav/base_closure8_alt3.res b/tests/sav/base_closure8_alt3.res deleted file mode 100644 index 5ee2929..0000000 --- a/tests/sav/base_closure8_alt3.res +++ /dev/null @@ -1,8 +0,0 @@ -0 -[1 -2 -[3 -4 -!3 -!1 -8 diff --git a/tests/sav/base_closure8_alt4.res b/tests/sav/base_closure8_alt4.res deleted file mode 100644 index 338aa5f..0000000 --- a/tests/sav/base_closure8_alt4.res +++ /dev/null @@ -1 +0,0 @@ -alt/base_closure8_alt4.nit:29,8--10: Error: no closure named '!baz' in bar; only closure is !break. diff --git a/tests/sav/base_closure9.res b/tests/sav/base_closure9.res deleted file mode 100644 index dd56d39..0000000 --- a/tests/sav/base_closure9.res +++ /dev/null @@ -1,322 +0,0 @@ -0 -[A,0 - [a,1 - [a,2 - {a,3 - {b,3 - {c,3 - C,0 - >c,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]c,1 - >b,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]b,1 - >a,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]a,1 -]C,0 ->B,0 - >c,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]c,1 - >b,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]b,1 - >a,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]a,1 -]B,0 ->A,0 - >c,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]c,1 - >b,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]b,1 - >a,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]a,1 -]A,0 -2 -3 diff --git a/tests/sav/base_closure9_alt1.res b/tests/sav/base_closure9_alt1.res deleted file mode 100644 index 3c1c4d6..0000000 --- a/tests/sav/base_closure9_alt1.res +++ /dev/null @@ -1,269 +0,0 @@ -0 -[A,0 - [a,1 - [a,2 - {a,3 - {b,3 - {c,3 - B,0 - >c,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]c,1 - >b,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]b,1 - >a,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]a,1 -]B,0 ->A,0 - >c,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]c,1 - >b,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]b,1 - >a,1 - >c,2 - }c,3 - }b,3 - }a,3 - ]c,2 - >b,2 - }c,3 - }b,3 - }a,3 - ]b,2 - >a,2 - }c,3 - }b,3 - }a,3 - ]a,2 - ]a,1 -]A,0 -2 -3 diff --git a/tests/sav/base_closure9_alt2.res b/tests/sav/base_closure9_alt2.res deleted file mode 100644 index a489514..0000000 --- a/tests/sav/base_closure9_alt2.res +++ /dev/null @@ -1,162 +0,0 @@ -0 -[A,0 - [a,1 - [a,2 - {a,3 - {b,3 - {c,3 - 2 - >1 - <1 - <2 - =20 - >2 - >1 - <1 - <2 - =30 - >2 - >1 ->0 diff --git a/tests/sav/test_closure_inlined_return_alt1.res b/tests/sav/test_closure_inlined_return_alt1.res deleted file mode 100644 index f558a2f..0000000 --- a/tests/sav/test_closure_inlined_return_alt1.res +++ /dev/null @@ -1,15 +0,0 @@ -<0 - <1 - <2 - =10 - >2 - >1 - <1 - <2 - =20 - <1 - <2 - =30 - >2 - >1 ->0 diff --git a/tests/sav/test_map_closure_default.res b/tests/sav/test_map_closure_default.res deleted file mode 100644 index b0a3084..0000000 --- a/tests/sav/test_map_closure_default.res +++ /dev/null @@ -1,12 +0,0 @@ -B: -true -blue -R: -false -red -true -red -N: -false -black -false diff --git a/tests/sav/test_map_closure_default_alt1.res b/tests/sav/test_map_closure_default_alt1.res deleted file mode 100644 index 786d676..0000000 --- a/tests/sav/test_map_closure_default_alt1.res +++ /dev/null @@ -1,13 +0,0 @@ -Runtime error: Aborted (alt/test_map_closure_default_alt1.nit:19) -B: -true -blue -R: -false -red -true -red -N: -false -black -false diff --git a/tests/test_closure_inlined_return.nit b/tests/test_closure_inlined_return.nit deleted file mode 100644 index cf5f034..0000000 --- a/tests/test_closure_inlined_return.nit +++ /dev/null @@ -1,42 +0,0 @@ -fun foo !k -do - ' '.output - '<'.output - 1.output - k - ' '.output - '>'.output - 1.output -end - -fun test -do - var a = [10, 20, 30] - '<'.output - 0.output - var i = 0 - while i < 3 do - foo !k do - ' '.output - ' '.output - '<'.output - 2.output - ' '.output - ' '.output - '='.output - a[i].output # a[i] is usually inlined - if i == 1 then - #alt1#break - end - ' '.output - ' '.output - '>'.output - 2.output - end - i += 1 - end - '>'.output - 0.output -end - -test diff --git a/tests/test_iterate.nit b/tests/test_iterate.nit deleted file mode 100644 index 9cfc2d8..0000000 --- a/tests/test_iterate.nit +++ /dev/null @@ -1,82 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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. - -fun test_iterator(c: Collection[Int]) -do - var idx = 0 - var it = c.iterator - while it.is_ok do - var i = it.item - print " {idx}->{i}" - it.next - idx += 1 - end -end - -fun test_iterate(c: Collection[Int]) -do - var idx = 0 - c.iterate !each i do - print " {idx}->{i}" - idx += 1 - end -end - -fun test_for(c: Collection[Int]) -do - var idx = 0 - for i in c do - print " {idx}->{i}" - idx += 1 - end -end - -fun test_coll(c: Collection[Int], s: String) -do - print("{s}: iterator") - test_iterator(c) - print("{s}: iterate") - test_iterate(c) - print("{s}: for") - test_for(c) - print("") -end - -fun init_seq(c: SimpleCollection[Int]): SimpleCollection[Int] -do - for i in [0..5[ do - c.add(i) - end - return c -end - -fun init_map(c: Map[Int, Int]): Map[Int, Int] -do - for i in [0..5[ do - c[i*10] = i - end - return c -end - -test_coll(init_seq(new Array[Int]), "Array") -test_coll(init_seq(new List[Int]), "List") -test_coll(init_seq(new ArraySet[Int]), "ArraySet") -test_coll(init_seq(new HashSet[Int]), "HashSet") -test_coll([0..5[, "ORange") -test_coll([0..4], "CRange") -test_coll(init_map(new ArrayMap[Int, Int]).values, "ArrayMap") -test_coll(init_map(new HashMap[Int, Int]).values, "HashMap") - diff --git a/tests/test_map_closure_default.nit b/tests/test_map_closure_default.nit deleted file mode 100644 index bc8371d..0000000 --- a/tests/test_map_closure_default.nit +++ /dev/null @@ -1,56 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# Copyright 2009 Jean Privat -# -# 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 Map[K, V] - fun get(k: K): V - !def: V do abort - do - if has_key(k) then return self[k] - var d = def - self[k] = d - return d - end -end - -var h = new HashMap[String, String] -h["bleu"] = "blue" - -print "B:" - -print h.has_key("bleu") -var v = h.get("bleu") !def do - print "Error" - abort -end -print v - -print "R:" - -print h.has_key("rouge") -v = h.get("rouge") !def do continue "red" -print v -print h.has_key("rouge") -v = h.get("rouge") -print v - -print "N:" - -print h.has_key("noir") -v = h.get("noir") !def do break "black" -print v -print h.has_key("noir") - -#alt1#v = h.get("noir")