From ddbab9ce0a80232fdce04def9f35aef24f9d2efd Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 10 Nov 2015 10:01:17 -0500 Subject: [PATCH] tests: add base_vararg_mult.nit Signed-off-by: Jean Privat --- tests/base_vararg_mult.nit | 51 +++++++++++++++++++++++++++++++++++ tests/sav/base_vararg_mult.res | 30 +++++++++++++++++++++ tests/sav/base_vararg_mult_alt1.res | 3 +++ 3 files changed, 84 insertions(+) create mode 100644 tests/base_vararg_mult.nit create mode 100644 tests/sav/base_vararg_mult.res create mode 100644 tests/sav/base_vararg_mult_alt1.res diff --git a/tests/base_vararg_mult.nit b/tests/base_vararg_mult.nit new file mode 100644 index 0000000..9f9bd0a --- /dev/null +++ b/tests/base_vararg_mult.nit @@ -0,0 +1,51 @@ +# 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 array + +class A + fun x(ints: Int...) is autoinit do + for i in ints do + 'X'.output + i.output + end + '\n'.output + end +end + +class B + super A + fun y(objs: Object...) is autoinit do + for i in objs do + 'Y'.output + i.output + end + '\n'.output + end +end + +var x + +#alt1#x = new A +x = new A(1) +x = new A(10, 20) +x = new A([100, 200, 300]...) + +#aly1#x = new B(1) +x = new B(1, 2) +#alt1#x = new B(1, 2, 3) +#alt1#x = new B([10, 20], 33) +x = new B([10, 11]..., 20) +x = new B(10, [20, 21]...) +x = new B([10, 11]..., [20, 21, 23]...) diff --git a/tests/sav/base_vararg_mult.res b/tests/sav/base_vararg_mult.res new file mode 100644 index 0000000..2776784 --- /dev/null +++ b/tests/sav/base_vararg_mult.res @@ -0,0 +1,30 @@ +X1 + +X10 +X20 + +X100 +X200 +X300 + +X1 + +Y2 + +X10 +X11 + +Y20 + +X10 + +Y20 +Y21 + +X10 +X11 + +Y20 +Y21 +Y23 + diff --git a/tests/sav/base_vararg_mult_alt1.res b/tests/sav/base_vararg_mult_alt1.res new file mode 100644 index 0000000..8189994 --- /dev/null +++ b/tests/sav/base_vararg_mult_alt1.res @@ -0,0 +1,3 @@ +alt/base_vararg_mult_alt1.nit:40,5--7: Error: expected at least 1 argument(s) for `init(ints: Int...)`; got 0. See introduction at `core::Object::init`. +alt/base_vararg_mult_alt1.nit:47,5--7: Error: expected 2 argument(s) for `init(ints: Int..., objs: Object...)`; got 3. See introduction at `core::Object::init`. +alt/base_vararg_mult_alt1.nit:48,11--18: Type Error: expected `Int`, got `Array[Int]`. Is an ellipsis `...` missing on the argument? -- 1.7.9.5