tests: add base_autocast_array.nit
authorJean Privat <jean@pryen.org>
Fri, 17 Apr 2015 00:45:32 +0000 (07:45 +0700)
committerJean Privat <jean@pryen.org>
Fri, 17 Apr 2015 02:09:18 +0000 (09:09 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_autocast_array.nit [new file with mode: 0644]
tests/sav/base_autocast_array.res [new file with mode: 0644]
tests/sav/base_autocast_array_alt1.res [new file with mode: 0644]
tests/sav/base_autocast_array_alt2.res [new file with mode: 0644]
tests/sav/base_autocast_array_alt3.res [new file with mode: 0644]
tests/sav/nitg-e/base_autocast_array_alt2.res [new file with mode: 0644]

diff --git a/tests/base_autocast_array.nit b/tests/base_autocast_array.nit
new file mode 100644 (file)
index 0000000..9beb291
--- /dev/null
@@ -0,0 +1,45 @@
+# 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 standard::collection::array
+
+class A
+       type V: nullable Object
+       var v: V
+
+       fun test_array: Array[V]
+       do
+               #alt3#v = 10
+               return [v] #alt1-2#
+               #alt1#return [10:V]
+               #alt2#return [10]
+       end
+end
+
+class B
+       super A
+       redef type V: Bool
+end
+
+var a = new A(1)
+
+a.test_array.first.output
+
+var ab = new A(true)
+
+ab.test_array.first.output
+
+var b = new B(true)
+
+b.test_array.first.output
diff --git a/tests/sav/base_autocast_array.res b/tests/sav/base_autocast_array.res
new file mode 100644 (file)
index 0000000..9acd049
--- /dev/null
@@ -0,0 +1,3 @@
+1
+true
+true
diff --git a/tests/sav/base_autocast_array_alt1.res b/tests/sav/base_autocast_array_alt1.res
new file mode 100644 (file)
index 0000000..0c8e503
--- /dev/null
@@ -0,0 +1 @@
+alt/base_autocast_array_alt1.nit:25,11--12: Type Error: expected `V`, got `Int`.
diff --git a/tests/sav/base_autocast_array_alt2.res b/tests/sav/base_autocast_array_alt2.res
new file mode 100644 (file)
index 0000000..f8e020c
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed. Expected `Array[V]`, got `Array[Int]` (alt/base_autocast_array_alt2.nit:26)
+10
+10
diff --git a/tests/sav/base_autocast_array_alt3.res b/tests/sav/base_autocast_array_alt3.res
new file mode 100644 (file)
index 0000000..a93fcc4
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed. Expected `V`, got `Int` (alt/base_autocast_array_alt3.nit:23)
+10
+10
diff --git a/tests/sav/nitg-e/base_autocast_array_alt2.res b/tests/sav/nitg-e/base_autocast_array_alt2.res
new file mode 100644 (file)
index 0000000..91b441c
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed (alt/base_autocast_array_alt2.nit:45)
+10
+10