tests: add base_collection.nit
authorJean Privat <jean@pryen.org>
Wed, 17 Jul 2013 17:12:27 +0000 (13:12 -0400)
committerJean Privat <jean@pryen.org>
Wed, 17 Jul 2013 17:12:27 +0000 (13:12 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_collection.nit [new file with mode: 0644]
tests/sav/base_collection.res [new file with mode: 0644]

diff --git a/tests/base_collection.nit b/tests/base_collection.nit
new file mode 100644 (file)
index 0000000..4256ebf
--- /dev/null
@@ -0,0 +1,65 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2006-2008 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 abstract_collection
+
+class A
+       fun foo do 1.output
+end
+
+class G[E]
+       super Collection[E]
+
+       var a: A
+
+       redef fun iterator do return new I[E](self)
+end
+
+class I[E]
+       super Iterator[E]
+
+       var g: G[E]
+       var fini: Bool = false
+
+       redef fun next
+       do
+               fini = true
+       end
+
+       redef fun is_ok
+       do
+               return not fini
+       end
+
+       redef fun item
+       do
+               return g.a
+       end
+end
+
+class B
+       var a = new A
+       var g = new G[A](a)
+
+       fun bar
+       do
+               for x in g do x.foo
+       end
+end
+
+var b = new B
+b.bar
+for x in b.g do x.foo
diff --git a/tests/sav/base_collection.res b/tests/sav/base_collection.res
new file mode 100644 (file)
index 0000000..6ed281c
--- /dev/null
@@ -0,0 +1,2 @@
+1
+1