tests: add test_array_formal.nit
authorJean Privat <jean@pryen.org>
Sun, 9 Dec 2012 05:33:26 +0000 (00:33 -0500)
committerJean Privat <jean@pryen.org>
Sun, 9 Dec 2012 06:37:54 +0000 (01:37 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/sav/fixme/test_array_formal.res [new file with mode: 0644]
tests/sav/niti/fixme/test_array_formal.res [new file with mode: 0644]
tests/sav/test_array_formal.res [new file with mode: 0644]
tests/test_array_formal.nit [new file with mode: 0644]

diff --git a/tests/sav/fixme/test_array_formal.res b/tests/sav/fixme/test_array_formal.res
new file mode 100644 (file)
index 0000000..b313f9a
--- /dev/null
@@ -0,0 +1,51 @@
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+
diff --git a/tests/sav/niti/fixme/test_array_formal.res b/tests/sav/niti/fixme/test_array_formal.res
new file mode 100644 (file)
index 0000000..6ad81db
--- /dev/null
@@ -0,0 +1,51 @@
+true
+true
+false
+
+true
+true
+false
+
+true
+true
+false
+
+true
+true
+false
+
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+
+true
+true
+false
+
+true
+true
+false
+
+true
+true
+false
+
+true
+true
+false
+
+
diff --git a/tests/sav/test_array_formal.res b/tests/sav/test_array_formal.res
new file mode 100644 (file)
index 0000000..23ae780
--- /dev/null
@@ -0,0 +1,51 @@
+true
+true
+false
+
+true
+true
+false
+
+true
+true
+false
+
+true
+true
+false
+
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+true
+true
+true
+
+
+true
+true
+false
+
+true
+true
+false
+
+true
+false
+false
+
+true
+false
+false
+
+
diff --git a/tests/test_array_formal.nit b/tests/test_array_formal.nit
new file mode 100644 (file)
index 0000000..1bcdeb8
--- /dev/null
@@ -0,0 +1,53 @@
+# 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 G[E]
+       type T: nullable Object
+
+       fun ae(e: E): Object do return [e]
+       fun at(t: T): Object do return [t]
+       fun ae2: Object do return new Array[E]
+       fun at2: Object do return new Array[T]
+end
+
+class GO
+       super G[Object]
+       redef type T: Object
+end
+
+class GI
+       super G[Int]
+       redef type T: Int
+end
+
+fun test(x: Object)
+do
+       (x isa Array[nullable Object]).output
+       (x isa Array[Object]).output
+       (x isa Array[Int]).output
+       '\n'.output
+end
+
+fun test2(x: G[Object])
+do
+       test(x.ae(1))
+       test(x.ae2)
+       test(x.at(2))
+       test(x.at2)
+       '\n'.output
+end
+
+test2(new GO)
+test2(new GI)
+test2(new G[Object])