tests: add base_virtual_type_fixed.nit
authorJean Privat <jean@pryen.org>
Wed, 23 Jul 2014 02:20:08 +0000 (22:20 -0400)
committerJean Privat <jean@pryen.org>
Wed, 23 Jul 2014 02:20:08 +0000 (22:20 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

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

diff --git a/tests/base_virtual_type_fixed.nit b/tests/base_virtual_type_fixed.nit
new file mode 100644 (file)
index 0000000..cc0248b
--- /dev/null
@@ -0,0 +1,38 @@
+# 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 V1: Object
+       fun v1(v: V1): V1 do return v
+       type V2: Object
+       fun v2(v: V2): V2 do return v
+end
+interface B
+       super A
+       redef type V1: Discrete
+       redef type V2: Discrete is fixed
+end
+class C
+       super B
+
+       # Because of the workaround, there is no simple way to see the subtype relation
+       #alt1#redef fun v1(v: Discrete): Discrete do return v
+       redef fun v2(v: Discrete): Discrete do return v
+end
+
+var c: A = new C
+c.v1(1).output
+c.v1(2).output
diff --git a/tests/sav/base_virtual_type_fixed.res b/tests/sav/base_virtual_type_fixed.res
new file mode 100644 (file)
index 0000000..1191247
--- /dev/null
@@ -0,0 +1,2 @@
+1
+2
diff --git a/tests/sav/base_virtual_type_fixed_alt1.res b/tests/sav/base_virtual_type_fixed_alt1.res
new file mode 100644 (file)
index 0000000..e1f51ca
--- /dev/null
@@ -0,0 +1,2 @@
+alt/base_virtual_type_fixed_alt1.nit:32,15--25: Redef Error: Wrong type for parameter `v'. found Discrete, expected V1 as in base_virtual_type_fixed_alt1#A#v1.
+alt/base_virtual_type_fixed_alt1.nit:32,29--36: Redef Error: Wrong return type. found Discrete, expected V1 as in base_virtual_type_fixed_alt1#A#v1.