From 34381b9f6f22995a69c1f073eb4e5343802f23b2 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 17 Apr 2015 07:45:32 +0700 Subject: [PATCH] tests: add base_autocast_array.nit Signed-off-by: Jean Privat --- tests/base_autocast_array.nit | 45 +++++++++++++++++++++++++ tests/sav/base_autocast_array.res | 3 ++ tests/sav/base_autocast_array_alt1.res | 1 + tests/sav/base_autocast_array_alt2.res | 3 ++ tests/sav/base_autocast_array_alt3.res | 3 ++ tests/sav/nitg-e/base_autocast_array_alt2.res | 3 ++ 6 files changed, 58 insertions(+) create mode 100644 tests/base_autocast_array.nit create mode 100644 tests/sav/base_autocast_array.res create mode 100644 tests/sav/base_autocast_array_alt1.res create mode 100644 tests/sav/base_autocast_array_alt2.res create mode 100644 tests/sav/base_autocast_array_alt3.res create mode 100644 tests/sav/nitg-e/base_autocast_array_alt2.res diff --git a/tests/base_autocast_array.nit b/tests/base_autocast_array.nit new file mode 100644 index 0000000..9beb291 --- /dev/null +++ b/tests/base_autocast_array.nit @@ -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 index 0000000..9acd049 --- /dev/null +++ b/tests/sav/base_autocast_array.res @@ -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 index 0000000..0c8e503 --- /dev/null +++ b/tests/sav/base_autocast_array_alt1.res @@ -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 index 0000000..f8e020c --- /dev/null +++ b/tests/sav/base_autocast_array_alt2.res @@ -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 index 0000000..a93fcc4 --- /dev/null +++ b/tests/sav/base_autocast_array_alt3.res @@ -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 index 0000000..91b441c --- /dev/null +++ b/tests/sav/nitg-e/base_autocast_array_alt2.res @@ -0,0 +1,3 @@ +Runtime error: Cast failed (alt/base_autocast_array_alt2.nit:45) +10 +10 -- 1.7.9.5