@@ -738,49 +738,57 @@ func TestCallable(t *testing.T) {
738738
739739 err = suite .verifyFunctionBehavior (`<?php
740740
741+ echo "Testing my_array_map([1, 2, 3])\n";
741742$result = my_array_map([1, 2, 3], function($x) { return $x * 2; });
742743if ($result !== [2, 4, 6]) {
743744 echo "FAIL: my_array_map with closure expected [2, 4, 6], got " . json_encode($result);
744745 exit(1);
745746}
746747
748+ echo "Testing my_array_map(['hello', 'world'])\n";
747749$result = my_array_map(['hello', 'world'], 'strtoupper');
748750if ($result !== ['HELLO', 'WORLD']) {
749751 echo "FAIL: my_array_map with function name expected ['HELLO', 'WORLD'], got " . json_encode($result);
750752 exit(1);
751753}
752754
755+ echo "Testing my_array_map with trim function\n";
753756$result = my_array_map([], function($x) { return $x; });
754757if ($result !== []) {
755758 echo "FAIL: my_array_map with empty array expected [], got " . json_encode($result);
756759 exit(1);
757760}
758761
762+ echo "Testing my_filter([1, 2, 3, 4, 5, 6])\n";
759763$result = my_filter([1, 2, 3, 4, 5, 6], function($x) { return $x % 2 === 0; });
760764if ($result !== [2, 4, 6]) {
761765 echo "FAIL: my_filter expected [2, 4, 6], got " . json_encode($result);
762766 exit(1);
763767}
764768
769+ echo "Testing my_filter with null callback\n";
765770$result = my_filter([1, 2, 3, 4], null);
766771if ($result !== [1, 2, 3, 4]) {
767772 echo "FAIL: my_filter with null callback expected [1, 2, 3, 4], got " . json_encode($result);
768773 exit(1);
769774}
770775
776+ echo "Testing Processor::transform\n";
771777$processor = new Processor();
772778$result = $processor->transform('hello', function($s) { return strtoupper($s); });
773779if ($result !== 'HELLO') {
774780 echo "FAIL: Processor::transform with closure expected 'HELLO', got '$result'";
775781 exit(1);
776782}
777783
784+ echo "Testing Processor::transform with function name\n";
778785$result = $processor->transform('world', 'strtoupper');
779786if ($result !== 'WORLD') {
780787 echo "FAIL: Processor::transform with function name expected 'WORLD', got '$result'";
781788 exit(1);
782789}
783790
791+ echo "Testing Processor::transform with trim function\n";
784792$result = $processor->transform(' test ', 'trim');
785793if ($result !== 'test') {
786794 echo "FAIL: Processor::transform with trim expected 'test', got '$result'";
0 commit comments