From 9e0a434f00a109bdfb3b3b25255a243ba700371c Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Sat, 30 Dec 2023 15:02:54 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- tests/sys/funcTest.php | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/sys/funcTest.php b/tests/sys/funcTest.php index 226f514..ab69e62 100644 --- a/tests/sys/funcTest.php +++ b/tests/sys/funcTest.php @@ -4,6 +4,11 @@ namespace { function func36() { return 36; } + + function m1($a): array { return [$a]; } + function m1o1($a, $b=1): array { return [$a, $b]; } + function m1v($a, ...$c): array { return [$a, ...$c]; } + function m1o1v($a, $b=1, ...$c): array { return [$a, $b, ...$c]; } } namespace nur\sery\sys { @@ -143,6 +148,48 @@ namespace nur\sery\sys { self::assertSame(21, func::call($closure)); } + function testFix_args() { + self::assertSame([null], func::call("m1")); + self::assertSame([null], func::call("m1", null)); + self::assertSame([null], func::call("m1", null, null)); + self::assertSame([null], func::call("m1", null, null, null)); + self::assertSame([null], func::call("m1", null, null, null, null)); + self::assertSame([1], func::call("m1", 1)); + self::assertSame([1], func::call("m1", 1, 2)); + self::assertSame([1], func::call("m1", 1, 2, 3)); + self::assertSame([1], func::call("m1", 1, 2, 3, 4)); + + self::assertSame([null, 1], func::call("m1o1")); + self::assertSame([null, 1], func::call("m1o1", null)); + self::assertSame([null, null], func::call("m1o1", null, null)); + self::assertSame([null, null], func::call("m1o1", null, null, null)); + self::assertSame([null, null], func::call("m1o1", null, null, null, null)); + self::assertSame([1, 1], func::call("m1o1", 1)); + self::assertSame([1, 2], func::call("m1o1", 1, 2)); + self::assertSame([1, 2], func::call("m1o1", 1, 2, 3)); + self::assertSame([1, 2], func::call("m1o1", 1, 2, 3, 4)); + + self::assertSame([null], func::call("m1v")); + self::assertSame([null], func::call("m1v", null)); + self::assertSame([null, null], func::call("m1v", null, null)); + self::assertSame([null, null, null], func::call("m1v", null, null, null)); + self::assertSame([null, null, null, null], func::call("m1v", null, null, null, null)); + self::assertSame([1], func::call("m1v", 1)); + self::assertSame([1, 2], func::call("m1v", 1, 2)); + self::assertSame([1, 2, 3], func::call("m1v", 1, 2, 3)); + self::assertSame([1, 2, 3, 4], func::call("m1v", 1, 2, 3, 4)); + + self::assertSame([null, 1], func::call("m1o1v")); + self::assertSame([null, 1], func::call("m1o1v", null)); + self::assertSame([null, null], func::call("m1o1v", null, null)); + self::assertSame([null, null, null], func::call("m1o1v", null, null, null)); + self::assertSame([null, null, null, null], func::call("m1o1v", null, null, null, null)); + self::assertSame([1, 1], func::call("m1o1v", 1)); + self::assertSame([1, 2], func::call("m1o1v", 1, 2)); + self::assertSame([1, 2, 3], func::call("m1o1v", 1, 2, 3)); + self::assertSame([1, 2, 3, 4], func::call("m1o1v", 1, 2, 3, 4)); + } + function testCall_all() { $c1 = new C1(); $c2 = new C2();