tests: add base_covar_int2.nit and base_virtual_int2.nit
authorJean Privat <jean@pryen.org>
Mon, 19 Aug 2013 16:46:04 +0000 (12:46 -0400)
committerJean Privat <jean@pryen.org>
Mon, 19 Aug 2013 16:46:04 +0000 (12:46 -0400)
But new compilers are broken since they do the type-adaptation before the
covariance check.

Signed-off-by: Jean Privat <jean@pryen.org>

28 files changed:
tests/base_covar_int2.nit [new file with mode: 0644]
tests/base_virtual_int2.nit [new file with mode: 0644]
tests/sav/base_covar_int2.res [new file with mode: 0644]
tests/sav/base_covar_int2_alt1.res [new file with mode: 0644]
tests/sav/base_covar_int2_alt1.sav [new file with mode: 0644]
tests/sav/base_covar_int2_alt2.res [new file with mode: 0644]
tests/sav/base_covar_int2_alt3.res [new file with mode: 0644]
tests/sav/base_covar_int2_alt3.sav [new file with mode: 0644]
tests/sav/base_covar_int2_alt4.res [new file with mode: 0644]
tests/sav/base_covar_int2_alt5.res [new file with mode: 0644]
tests/sav/base_covar_int2_alt5.sav [new file with mode: 0644]
tests/sav/base_virtual_int2.res [new file with mode: 0644]
tests/sav/base_virtual_int2_alt1.res [new file with mode: 0644]
tests/sav/base_virtual_int2_alt2.res [new file with mode: 0644]
tests/sav/base_virtual_int2_alt2.sav [new file with mode: 0644]
tests/sav/base_virtual_int2_alt3.res [new file with mode: 0644]
tests/sav/nitg-e/fixme/base_covar_int2_alt1.res [new file with mode: 0644]
tests/sav/nitg-e/fixme/base_covar_int2_alt3.res [new file with mode: 0644]
tests/sav/nitg-e/fixme/base_covar_int2_alt5.res [new file with mode: 0644]
tests/sav/nitg-e/fixme/base_virtual_int2_alt2.res [new file with mode: 0644]
tests/sav/nitg-s/fixme/base_covar_int2_alt1.res [new file with mode: 0644]
tests/sav/nitg-s/fixme/base_covar_int2_alt3.res [new file with mode: 0644]
tests/sav/nitg-s/fixme/base_covar_int2_alt5.res [new file with mode: 0644]
tests/sav/nitg-s/fixme/base_virtual_int2_alt2.res [new file with mode: 0644]
tests/sav/nitg/fixme/base_covar_int2_alt1.res [new file with mode: 0644]
tests/sav/nitg/fixme/base_covar_int2_alt3.res [new file with mode: 0644]
tests/sav/nitg/fixme/base_covar_int2_alt5.res [new file with mode: 0644]
tests/sav/nitg/fixme/base_virtual_int2_alt2.res [new file with mode: 0644]

diff --git a/tests/base_covar_int2.nit b/tests/base_covar_int2.nit
new file mode 100644 (file)
index 0000000..550f651
--- /dev/null
@@ -0,0 +1,46 @@
+# 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
+
+interface A
+       type V: A
+       fun foo(v: V): V is abstract
+end
+
+redef class Int
+       super A
+       redef type V: Int
+       redef fun foo(v) do return self
+end
+
+redef class Char
+       super A
+       redef type V: Char
+       redef fun foo(v) do return self
+end
+
+var d1: A = 1
+var d2: A = 2
+var c1: A = 'a'
+var c2: A = 'b'
+1.foo(2).output
+d1.foo(2).output
+#alt1#c1.foo(2).output
+#alt2#1.foo(d2).output
+d1.foo(d2).output
+#alt3#c1.foo(d2).output
+#alt4#1.foo(c2).output
+#alt5#d1.foo(c2).output
+c1.foo(c2).output
diff --git a/tests/base_virtual_int2.nit b/tests/base_virtual_int2.nit
new file mode 100644 (file)
index 0000000..f35b11a
--- /dev/null
@@ -0,0 +1,43 @@
+# 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
+
+interface A
+       type V: A
+       fun foo(v: V): V is abstract
+end
+
+redef class Int
+       super A
+       redef type V: Int
+       redef fun foo(v) do return self
+end
+
+redef class Char
+       super A
+       redef type V: Char
+       redef fun foo(v) do return self
+end
+
+fun test(d: A)
+do
+       d.foo(5).output
+       #alt1#3.foo(d).output
+       d.foo(d).output
+       #alt2#d.foo('a').output
+       #alt3#5.as(A).foo(d).output
+end
+
+test(4)
diff --git a/tests/sav/base_covar_int2.res b/tests/sav/base_covar_int2.res
new file mode 100644 (file)
index 0000000..33afcf3
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+1
+a
\ No newline at end of file
diff --git a/tests/sav/base_covar_int2_alt1.res b/tests/sav/base_covar_int2_alt1.res
new file mode 100644 (file)
index 0000000..082b9bb
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed (alt/base_covar_int2_alt1.nit:31)
+1
+1
diff --git a/tests/sav/base_covar_int2_alt1.sav b/tests/sav/base_covar_int2_alt1.sav
new file mode 100644 (file)
index 0000000..a068496
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed (alt/base_covar_int2_alt1.nit)
+1
+1
diff --git a/tests/sav/base_covar_int2_alt2.res b/tests/sav/base_covar_int2_alt2.res
new file mode 100644 (file)
index 0000000..160f623
--- /dev/null
@@ -0,0 +1 @@
+alt/base_covar_int2_alt2.nit:41,7--8: Type error: expected Int, got A
diff --git a/tests/sav/base_covar_int2_alt3.res b/tests/sav/base_covar_int2_alt3.res
new file mode 100644 (file)
index 0000000..8ef66ae
--- /dev/null
@@ -0,0 +1,4 @@
+Runtime error: Cast failed (alt/base_covar_int2_alt3.nit:31)
+1
+1
+1
diff --git a/tests/sav/base_covar_int2_alt3.sav b/tests/sav/base_covar_int2_alt3.sav
new file mode 100644 (file)
index 0000000..c1ad514
--- /dev/null
@@ -0,0 +1,4 @@
+Runtime error: Cast failed (alt/base_covar_int2_alt3.nit)
+1
+1
+1
diff --git a/tests/sav/base_covar_int2_alt4.res b/tests/sav/base_covar_int2_alt4.res
new file mode 100644 (file)
index 0000000..16397e7
--- /dev/null
@@ -0,0 +1 @@
+alt/base_covar_int2_alt4.nit:44,7--8: Type error: expected Int, got A
diff --git a/tests/sav/base_covar_int2_alt5.res b/tests/sav/base_covar_int2_alt5.res
new file mode 100644 (file)
index 0000000..37bc196
--- /dev/null
@@ -0,0 +1,4 @@
+Runtime error: Cast failed (alt/base_covar_int2_alt5.nit:25)
+1
+1
+1
diff --git a/tests/sav/base_covar_int2_alt5.sav b/tests/sav/base_covar_int2_alt5.sav
new file mode 100644 (file)
index 0000000..74caff9
--- /dev/null
@@ -0,0 +1,4 @@
+Runtime error: Cast failed (alt/base_covar_int2_alt5.nit)
+1
+1
+1
diff --git a/tests/sav/base_virtual_int2.res b/tests/sav/base_virtual_int2.res
new file mode 100644 (file)
index 0000000..7290ba8
--- /dev/null
@@ -0,0 +1,2 @@
+4
+4
diff --git a/tests/sav/base_virtual_int2_alt1.res b/tests/sav/base_virtual_int2_alt1.res
new file mode 100644 (file)
index 0000000..fba7b1d
--- /dev/null
@@ -0,0 +1 @@
+alt/base_virtual_int2_alt1.nit:37,8: Type error: expected Int, got A
diff --git a/tests/sav/base_virtual_int2_alt2.res b/tests/sav/base_virtual_int2_alt2.res
new file mode 100644 (file)
index 0000000..2dbe41a
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed (alt/base_virtual_int2_alt2.nit:25)
+4
+4
diff --git a/tests/sav/base_virtual_int2_alt2.sav b/tests/sav/base_virtual_int2_alt2.sav
new file mode 100644 (file)
index 0000000..1366eb4
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed (alt/base_virtual_int2_alt2.nit)
+4
+4
diff --git a/tests/sav/base_virtual_int2_alt3.res b/tests/sav/base_virtual_int2_alt3.res
new file mode 100644 (file)
index 0000000..e0ff799
--- /dev/null
@@ -0,0 +1,4 @@
+alt/base_virtual_int2_alt3.nit:40,2--8: Warning: Expression is already a A since it is a Int.
+4
+4
+5
diff --git a/tests/sav/nitg-e/fixme/base_covar_int2_alt1.res b/tests/sav/nitg-e/fixme/base_covar_int2_alt1.res
new file mode 100644 (file)
index 0000000..66eae84
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+a1
+a
\ No newline at end of file
diff --git a/tests/sav/nitg-e/fixme/base_covar_int2_alt3.res b/tests/sav/nitg-e/fixme/base_covar_int2_alt3.res
new file mode 100644 (file)
index 0000000..f20caf3
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+1
+aa
\ No newline at end of file
diff --git a/tests/sav/nitg-e/fixme/base_covar_int2_alt5.res b/tests/sav/nitg-e/fixme/base_covar_int2_alt5.res
new file mode 100644 (file)
index 0000000..b3369df
--- /dev/null
@@ -0,0 +1,5 @@
+1
+1
+1
+1
+a
\ No newline at end of file
diff --git a/tests/sav/nitg-e/fixme/base_virtual_int2_alt2.res b/tests/sav/nitg-e/fixme/base_virtual_int2_alt2.res
new file mode 100644 (file)
index 0000000..2e435a2
--- /dev/null
@@ -0,0 +1,3 @@
+4
+4
+4
diff --git a/tests/sav/nitg-s/fixme/base_covar_int2_alt1.res b/tests/sav/nitg-s/fixme/base_covar_int2_alt1.res
new file mode 100644 (file)
index 0000000..66eae84
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+a1
+a
\ No newline at end of file
diff --git a/tests/sav/nitg-s/fixme/base_covar_int2_alt3.res b/tests/sav/nitg-s/fixme/base_covar_int2_alt3.res
new file mode 100644 (file)
index 0000000..f20caf3
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+1
+aa
\ No newline at end of file
diff --git a/tests/sav/nitg-s/fixme/base_covar_int2_alt5.res b/tests/sav/nitg-s/fixme/base_covar_int2_alt5.res
new file mode 100644 (file)
index 0000000..b3369df
--- /dev/null
@@ -0,0 +1,5 @@
+1
+1
+1
+1
+a
\ No newline at end of file
diff --git a/tests/sav/nitg-s/fixme/base_virtual_int2_alt2.res b/tests/sav/nitg-s/fixme/base_virtual_int2_alt2.res
new file mode 100644 (file)
index 0000000..2e435a2
--- /dev/null
@@ -0,0 +1,3 @@
+4
+4
+4
diff --git a/tests/sav/nitg/fixme/base_covar_int2_alt1.res b/tests/sav/nitg/fixme/base_covar_int2_alt1.res
new file mode 100644 (file)
index 0000000..88b3043
--- /dev/null
@@ -0,0 +1,3 @@
+1
+1
+Cast error: Cannot cast Int to Char.
diff --git a/tests/sav/nitg/fixme/base_covar_int2_alt3.res b/tests/sav/nitg/fixme/base_covar_int2_alt3.res
new file mode 100644 (file)
index 0000000..f20caf3
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+1
+aa
\ No newline at end of file
diff --git a/tests/sav/nitg/fixme/base_covar_int2_alt5.res b/tests/sav/nitg/fixme/base_covar_int2_alt5.res
new file mode 100644 (file)
index 0000000..b3369df
--- /dev/null
@@ -0,0 +1,5 @@
+1
+1
+1
+1
+a
\ No newline at end of file
diff --git a/tests/sav/nitg/fixme/base_virtual_int2_alt2.res b/tests/sav/nitg/fixme/base_virtual_int2_alt2.res
new file mode 100644 (file)
index 0000000..463b904
--- /dev/null
@@ -0,0 +1,3 @@
+4
+4
+Cast error: Cannot cast Char to Int.