From: Jean Privat Date: Mon, 21 Jul 2014 14:58:43 +0000 (-0400) Subject: tests: add base_init_noinit X-Git-Tag: v0.6.7~33^2 X-Git-Url: http://nitlanguage.org tests: add base_init_noinit Signed-off-by: Jean Privat --- diff --git a/tests/base_init_noinit.nit b/tests/base_init_noinit.nit new file mode 100644 index 0000000..87de46e --- /dev/null +++ b/tests/base_init_noinit.nit @@ -0,0 +1,31 @@ +# 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 + +class A + var x: Object is noinit #alt1,3# var x: Object + var y: Object is noinit #alt2,3# var y: Object + fun work + do + if isset _x then x.output + if isset _y then y.output + 0.output + end + #alt5#var z: Object = 5 is noinit +end + +var a: A +a = new A#alt1#a = new A(2)#alt2#a = new A(30)#alt3#a = new A(4, 40)#alt4#a=new A(5) +a.work diff --git a/tests/sav/base_init_noinit.res b/tests/sav/base_init_noinit.res new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/sav/base_init_noinit.res @@ -0,0 +1 @@ +0 diff --git a/tests/sav/base_init_noinit_alt1.res b/tests/sav/base_init_noinit_alt1.res new file mode 100644 index 0000000..389e262 --- /dev/null +++ b/tests/sav/base_init_noinit_alt1.res @@ -0,0 +1,2 @@ +2 +0 diff --git a/tests/sav/base_init_noinit_alt2.res b/tests/sav/base_init_noinit_alt2.res new file mode 100644 index 0000000..f4b9eda --- /dev/null +++ b/tests/sav/base_init_noinit_alt2.res @@ -0,0 +1,2 @@ +30 +0 diff --git a/tests/sav/base_init_noinit_alt3.res b/tests/sav/base_init_noinit_alt3.res new file mode 100644 index 0000000..84cd911 --- /dev/null +++ b/tests/sav/base_init_noinit_alt3.res @@ -0,0 +1,3 @@ +4 +40 +0 diff --git a/tests/sav/base_init_noinit_alt4.res b/tests/sav/base_init_noinit_alt4.res new file mode 100644 index 0000000..0e9d1ef --- /dev/null +++ b/tests/sav/base_init_noinit_alt4.res @@ -0,0 +1 @@ +alt/base_init_noinit_alt4.nit:30,3--10: Error: Incorrect number of parameters. Got 1, expected 0. Signature is diff --git a/tests/sav/base_init_noinit_alt5.res b/tests/sav/base_init_noinit_alt5.res new file mode 100644 index 0000000..b79ac75 --- /dev/null +++ b/tests/sav/base_init_noinit_alt5.res @@ -0,0 +1 @@ +alt/base_init_noinit_alt5.nit:26,23--28: Error: `noinit` attributes cannot have an initial value