tests: add base_vararg_mult.nit
authorJean Privat <jean@pryen.org>
Tue, 10 Nov 2015 15:01:17 +0000 (10:01 -0500)
committerJean Privat <jean@pryen.org>
Tue, 10 Nov 2015 15:01:17 +0000 (10:01 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_vararg_mult.nit [new file with mode: 0644]
tests/sav/base_vararg_mult.res [new file with mode: 0644]
tests/sav/base_vararg_mult_alt1.res [new file with mode: 0644]

diff --git a/tests/base_vararg_mult.nit b/tests/base_vararg_mult.nit
new file mode 100644 (file)
index 0000000..9f9bd0a
--- /dev/null
@@ -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 (file)
index 0000000..2776784
--- /dev/null
@@ -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 (file)
index 0000000..8189994
--- /dev/null
@@ -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?