From eeab8d6c81514b4e95988dbe2bfa1a043ce43a60 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sat, 18 Apr 2015 22:11:40 +0700 Subject: [PATCH] tests: add base_arg_named.nit and base_arg_order.nit Signed-off-by: Jean Privat --- tests/base_arg_named.nit | 46 +++++++++++++++++++ tests/base_arg_order.nit | 42 +++++++++++++++++ tests/sav/base_arg_named.res | 89 +++++++++++++++++++++++++++++++++++++ tests/sav/base_arg_named_alt1.res | 4 ++ tests/sav/base_arg_order.res | 73 ++++++++++++++++++++++++++++++ 5 files changed, 254 insertions(+) create mode 100644 tests/base_arg_named.nit create mode 100644 tests/base_arg_order.nit create mode 100644 tests/sav/base_arg_named.res create mode 100644 tests/sav/base_arg_named_alt1.res create mode 100644 tests/sav/base_arg_order.res diff --git a/tests/base_arg_named.nit b/tests/base_arg_named.nit new file mode 100644 index 0000000..a584add --- /dev/null +++ b/tests/base_arg_named.nit @@ -0,0 +1,46 @@ +# 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 base_arg_default + +var a = new A +a.foo(a=1,b=2,3,4,e=5,f=6) +a.foo(f=6,3,e=5,b=2,4,a=1) +a.foo(3,e=5,b=2,4) + +a.bar + +a.bar(a=1) +a.bar(2,a=1) +a.bar(2,a=1,3) +a.bar(b=2) +a.bar(1,b=2) +a.bar(1,b=2,3) +a.bar(c=3) +a.bar(1,c=3) +a.bar(1,c=3,2) + +a.bar(a=1,b=2) +a.bar(a=1,3,b=2) +a.bar(a=1,c=3) +a.bar(a=1,2,c=3) +a.bar(b=2,c=3) +a.bar(b=2,1,c=3) + +a.bar(b=2,a=1,c=3) + +#alt1#a.bar(2,a=1,3, 4) +#alt1#a.bar(fail=1) +#alt1#a.bar(a=1,a=1) +#alt1#a.foo(c=1,d=1) diff --git a/tests/base_arg_order.nit b/tests/base_arg_order.nit new file mode 100644 index 0000000..a948eeb --- /dev/null +++ b/tests/base_arg_order.nit @@ -0,0 +1,42 @@ +# 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 base_arg_default +import standard::collection::array + +fun order(i: Int): Int do + '>'.output + i.output + return i +end + +fun bar(a: Int, bs: Int..., c: Int) +do + a.output + for b in bs do + ' '.output + b.output + end + c.output +end + +var a = new A +a.foo(order(1),order(2),order(3),order(4),order(5),order(6)) +a.foo(a=order(1),b=order(2),order(3),order(4),e=order(5),f=order(6)) +a.foo(f=order(6),order(3),e=order(5),b=order(2),order(4),a=order(1)) +a.foo(order(3),e=order(5),b=order(2),order(4)) +a.foo(order(3),order(4)) + +bar(order(1),order(2),order(3)) +bar(order(1),order(2),order(3),order(4)) diff --git a/tests/sav/base_arg_named.res b/tests/sav/base_arg_named.res new file mode 100644 index 0000000..be2e49f --- /dev/null +++ b/tests/sav/base_arg_named.res @@ -0,0 +1,89 @@ +1 +2 +3 +4 +5 +6 +- +1 +2 +3 +4 +5 +6 +- + +2 +3 +4 +5 + +- + + + +- +1 + + +- +1 +2 + +- +1 +2 +3 +- + +2 + +- +1 +2 + +- +1 +2 +3 +- + + +3 +- +1 + +3 +- +1 +2 +3 +- +1 +2 + +- +1 +2 +3 +- +1 + +3 +- +1 +2 +3 +- + +2 +3 +- +1 +2 +3 +- +1 +2 +3 +- diff --git a/tests/sav/base_arg_named_alt1.res b/tests/sav/base_arg_named_alt1.res new file mode 100644 index 0000000..f41b60a --- /dev/null +++ b/tests/sav/base_arg_named_alt1.res @@ -0,0 +1,4 @@ +alt/base_arg_named_alt1.nit:43,3--5: Error: expected at most 3 argument(s) for `bar(a: nullable Int, b: nullable Int, c: nullable Int)`; got 4. See introduction at `base_arg_default::A::bar`. +alt/base_arg_named_alt1.nit:44,7--10: Error: no parameter `fail` for `bar(a: nullable Int, b: nullable Int, c: nullable Int)`. +alt/base_arg_named_alt1.nit:45,11--13: Error: parameter `a` already associated with argument #0 for `bar(a: nullable Int, b: nullable Int, c: nullable Int)`. +alt/base_arg_named_alt1.nit:46,7--9: Error: parameter `c` is not optional for `foo(a: nullable Int, b: nullable Int, c: Int, d: Int, e: nullable Int, f: nullable Int)`. diff --git a/tests/sav/base_arg_order.res b/tests/sav/base_arg_order.res new file mode 100644 index 0000000..b16bf3f --- /dev/null +++ b/tests/sav/base_arg_order.res @@ -0,0 +1,73 @@ +>1 +>2 +>3 +>4 +>5 +>6 +1 +2 +3 +4 +5 +6 +- +>1 +>2 +>3 +>4 +>5 +>6 +1 +2 +3 +4 +5 +6 +- +>6 +>3 +>5 +>2 +>4 +>1 +1 +2 +3 +4 +5 +6 +- +>3 +>5 +>2 +>4 + +2 +3 +4 +5 + +- +>3 +>4 + + +3 +4 + + +- +>1 +>2 +>3 +1 + 2 +3 +>1 +>2 +>3 +>4 +1 + 2 + 3 +4 -- 1.7.9.5