From 3b2c04a2c574e2919c8e28c3e8f2b2752099e226 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 29 Oct 2014 13:25:09 -0400 Subject: [PATCH] tests: add base_init_autoinit2.nit Signed-off-by: Jean Privat --- tests/base_init_autoinit2.nit | 43 ++++++++++++++++++++++++++++++++ tests/sav/base_init_autoinit2.res | 11 ++++++++ tests/sav/base_init_autoinit2_alt1.res | 1 + tests/sav/base_init_autoinit2_alt2.res | 1 + 4 files changed, 56 insertions(+) create mode 100644 tests/base_init_autoinit2.nit create mode 100644 tests/sav/base_init_autoinit2.res create mode 100644 tests/sav/base_init_autoinit2_alt1.res create mode 100644 tests/sav/base_init_autoinit2_alt2.res diff --git a/tests/base_init_autoinit2.nit b/tests/base_init_autoinit2.nit new file mode 100644 index 0000000..afce0f9 --- /dev/null +++ b/tests/base_init_autoinit2.nit @@ -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 + +class A + var a: Object = get(5) is lazy + var b: Object is noinit + #alt1#var b2: Object = get(-4) is noinit + var c: Object is noinit + var d: Object = get(2) is autoinit + #alt2#var d2: Object = get(-2) is autoinit, lazy + var e: Object = get(1) + fun setc(v: Object) is autoinit do self.c = get(v) + init do + b = get(4) + end + fun get(v: Object): Object + do + 'g'.output + v.output + return v + end +end + +var a = new A(3) +'\n'.output +a.a.output +a.b.output +a.c.output +a.d.output +a.e.output diff --git a/tests/sav/base_init_autoinit2.res b/tests/sav/base_init_autoinit2.res new file mode 100644 index 0000000..243898c --- /dev/null +++ b/tests/sav/base_init_autoinit2.res @@ -0,0 +1,11 @@ +g1 +g2 +g3 +g4 + +g5 +5 +4 +3 +2 +1 diff --git a/tests/sav/base_init_autoinit2_alt1.res b/tests/sav/base_init_autoinit2_alt1.res new file mode 100644 index 0000000..9c9fbe0 --- /dev/null +++ b/tests/sav/base_init_autoinit2_alt1.res @@ -0,0 +1 @@ +alt/base_init_autoinit2_alt1.nit:20,30--35: Error: `noinit` attributes cannot have an initial value diff --git a/tests/sav/base_init_autoinit2_alt2.res b/tests/sav/base_init_autoinit2_alt2.res new file mode 100644 index 0000000..3c28719 --- /dev/null +++ b/tests/sav/base_init_autoinit2_alt2.res @@ -0,0 +1 @@ +alt/base_init_autoinit2_alt2.nit:23,40--43: Error: lazy incompatible with autoinit -- 1.7.9.5