kraghuba                Fri Oct 19 18:22:56 2007 UTC

  Modified files:              
    /php-src/ext/standard/tests/array   array_filter_variation5.phpt 
                                        array_filter_variation6.phpt 
                                        array_filter_variation7.phpt 
                                        array_filter_variation8.phpt 
                                        array_filter_variation9.phpt 
                                        array_filter_error.phpt 
                                        array_filter_basic.phpt 
                                        array_filter_variation1.phpt 
                                        array_filter_variation2.phpt 
                                        array_filter_variation3.phpt 
                                        array_filter_variation4.phpt 
  Log:
  New testcases for array_filter() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation5.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation5.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:55 2007
+++ php-src/ext/standard/tests/array/array_filter_variation5.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,151 @@
+--TEST--
+Test array_filter() function : usage variations - 'input' argument with 
different false entries
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* With default callback function argument, array_filter() removes elements 
which are interpreted as false 
+* Here Testing all the false array element possibilities
+*/
+
+// callback function always_true
+function always_true($input)
+{
+  return true;
+}
+
+// callback function always_false
+function always_false($input)
+{
+  return false;
+}
+
+echo "*** Testing array_filter() : usage variations - different false elements 
in 'input' ***\n";
+
+// unset variable
+$unset_var = 10;
+unset($unset_var);
+
+// empty heredoc string
+$empty_heredoc =<<<EOT
+EOT;
+
+// input array with different false elements
+$input = array(
+  false,
+  False,
+  '',
+  "",
+  0,
+  0.0,
+  null,
+  NULL,
+  "0",
+  '0',
+  array(),
+  !1,
+  1==2,
+  $empty_heredoc,
+  @$unset_var,
+  @$undefined_var,
+);
+
+// With default callback function
+var_dump( array_filter($input) );  
+
+// With callback function which returns always true
+var_dump( array_filter($input, 'always_true') ); 
+
+// With callback function which returns always false
+var_dump( array_filter($input, 'always_false') );  
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - different false elements in 
'input' ***
+array(0) {
+}
+array(16) {
+  [0]=>
+  bool(false)
+  [1]=>
+  bool(false)
+  [2]=>
+  string(0) ""
+  [3]=>
+  string(0) ""
+  [4]=>
+  int(0)
+  [5]=>
+  float(0)
+  [6]=>
+  NULL
+  [7]=>
+  NULL
+  [8]=>
+  string(1) "0"
+  [9]=>
+  string(1) "0"
+  [10]=>
+  array(0) {
+  }
+  [11]=>
+  bool(false)
+  [12]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+  [14]=>
+  NULL
+  [15]=>
+  NULL
+}
+array(0) {
+}
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - different false elements in 
'input' ***
+array(0) {
+}
+array(16) {
+  [0]=>
+  bool(false)
+  [1]=>
+  bool(false)
+  [2]=>
+  unicode(0) ""
+  [3]=>
+  unicode(0) ""
+  [4]=>
+  int(0)
+  [5]=>
+  float(0)
+  [6]=>
+  NULL
+  [7]=>
+  NULL
+  [8]=>
+  unicode(1) "0"
+  [9]=>
+  unicode(1) "0"
+  [10]=>
+  array(0) {
+  }
+  [11]=>
+  bool(false)
+  [12]=>
+  bool(false)
+  [13]=>
+  unicode(0) ""
+  [14]=>
+  NULL
+  [15]=>
+  NULL
+}
+array(0) {
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation6.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation6.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation6.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:55 2007
+++ php-src/ext/standard/tests/array/array_filter_variation6.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,143 @@
+--TEST--
+Test array_filter() function : usage variations - 'input' array containing 
references 
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing 'input' array which contains elements as reference to other data
+*/
+
+echo "*** Testing array_filter() : usage variations - 'input' containing 
references ***\n";
+
+// Callback function
+/* Prototype : bool callback(array $input)
+ * Parameter : $input - array of which each element need to be checked in 
function
+ * Return Type : returns true or false
+ * Description : This function checks each element of an input array if 
element > 5 then
+ * returns true else returns false
+ */
+function callback($input)
+{
+  if($input > 5) {
+    return true;
+  }
+  else {
+    return false;
+  }
+}
+  
+// initializing variables
+$value1 = array(1, 2, 8);
+$value2 = array(5, 6, 4);
+$input = array(&$value1, 10, &$value2, 'value');
+
+// with 'callback' argument
+var_dump( array_filter($input, 'callback') );
+
+// with default 'callback' argument
+var_dump( array_filter($input) ); 
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - 'input' containing references 
***
+array(3) {
+  [0]=>
+  &array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(8)
+  }
+  [1]=>
+  int(10)
+  [2]=>
+  &array(3) {
+    [0]=>
+    int(5)
+    [1]=>
+    int(6)
+    [2]=>
+    int(4)
+  }
+}
+array(4) {
+  [0]=>
+  &array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(8)
+  }
+  [1]=>
+  int(10)
+  [2]=>
+  &array(3) {
+    [0]=>
+    int(5)
+    [1]=>
+    int(6)
+    [2]=>
+    int(4)
+  }
+  [3]=>
+  string(5) "value"
+}
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - 'input' containing references 
***
+array(3) {
+  [0]=>
+  &array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(8)
+  }
+  [1]=>
+  int(10)
+  [2]=>
+  &array(3) {
+    [0]=>
+    int(5)
+    [1]=>
+    int(6)
+    [2]=>
+    int(4)
+  }
+}
+array(4) {
+  [0]=>
+  &array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(8)
+  }
+  [1]=>
+  int(10)
+  [2]=>
+  &array(3) {
+    [0]=>
+    int(5)
+    [1]=>
+    int(6)
+    [2]=>
+    int(4)
+  }
+  [3]=>
+  unicode(5) "value"
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation7.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation7.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation7.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:55 2007
+++ php-src/ext/standard/tests/array/array_filter_variation7.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,125 @@
+--TEST--
+Test array_filter() function : usage variations - anonymous callback functions 
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing different anonymous callback functions with passed by value and 
reference arguments
+*/
+
+echo "*** Testing array_filter() : usage variations - Anonymous callback 
functions ***\n";
+
+$input = array(0, 1, -1, 10, 100, 1000, 'Hello', null);
+
+// anonymous callback function
+echo "Anonymous callback function with regular parameter and statement\n";
+var_dump( array_filter($input, create_function('$input', 'return ($input > 
1);') ) );
+
+// anonymous callback function with reference
+echo "Anonymous callback function with reference parameter\n";
+var_dump( array_filter($input, create_function('&$input', 'return ($input < 
1);') ) );
+
+// anonymous callback function with null argument
+echo "Anonymous callback funciton with null argument\n";
+var_dump( array_filter($input, create_function(null, 'return true;') ) );
+
+// anonymous callback function with argument and null statement
+echo "Anonymous callback function with regular argument and null statement\n";
+var_dump( array_filter($input, create_function('$input', null) ) );
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - Anonymous callback functions 
***
+Anonymous callback function with regular parameter and statement
+array(3) {
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+}
+Anonymous callback function with reference parameter
+array(4) {
+  [0]=>
+  int(0)
+  [2]=>
+  int(-1)
+  [6]=>
+  string(5) "Hello"
+  [7]=>
+  NULL
+}
+Anonymous callback funciton with null argument
+array(8) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  string(5) "Hello"
+  [7]=>
+  NULL
+}
+Anonymous callback function with regular argument and null statement
+array(0) {
+}
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - Anonymous callback functions 
***
+Anonymous callback function with regular parameter and statement
+array(3) {
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+}
+Anonymous callback function with reference parameter
+array(4) {
+  [0]=>
+  int(0)
+  [2]=>
+  int(-1)
+  [6]=>
+  unicode(5) "Hello"
+  [7]=>
+  NULL
+}
+Anonymous callback funciton with null argument
+array(8) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  unicode(5) "Hello"
+  [7]=>
+  NULL
+}
+Anonymous callback function with regular argument and null statement
+array(0) {
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation8.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation8.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation8.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:55 2007
+++ php-src/ext/standard/tests/array/array_filter_variation8.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,241 @@
+--TEST--
+Test array_filter() function : usage variations - Callback function with 
different return values 
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* callback functions are expected to return bool value for array_filter()
+* here testing callback functions for return values other than bool
+*/
+
+echo "*** Testing array_filter() : usage variations - callback function with 
different return values***\n";
+
+$input = array(0, 1, -1, 10, 100, 1000, 'Hello', null, true);
+
+// callback functions
+// int as return value
+function callback1($input)
+{
+  return 5;
+}
+echo "callback function with int return value\n";
+var_dump( array_filter($input, 'callback1') );
+
+// float as return value
+function callback2($input)
+{
+  return 3.4;
+}
+echo "callback function with float return value\n";
+var_dump( array_filter($input, 'callback2') );
+
+// string as return value
+function callback3($input)
+{
+  return 'value';
+}
+echo "callback function with string return value\n";
+var_dump( array_filter($input, 'callback3') );
+
+// null as return value
+function callback4($input)
+{
+  return null;
+}
+echo "callback function with null return value\n";
+var_dump( array_filter($input, 'callback4') );
+
+// array as return value
+function callback5($input)
+{
+  return array(8);
+}
+echo "callback function with array as return value\n";
+var_dump( array_filter($input, 'callback5') );
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - callback function with 
different return values***
+callback function with int return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  string(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+callback function with float return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  string(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+callback function with string return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  string(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+callback function with null return value
+array(0) {
+}
+callback function with array as return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  string(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - callback function with 
different return values***
+callback function with int return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  unicode(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+callback function with float return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  unicode(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+callback function with string return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  unicode(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+callback function with null return value
+array(0) {
+}
+callback function with array as return value
+array(9) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  unicode(5) "Hello"
+  [7]=>
+  NULL
+  [8]=>
+  bool(true)
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation9.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation9.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation9.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:55 2007
+++ php-src/ext/standard/tests/array/array_filter_variation9.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,113 @@
+--TEST--
+Test array_filter() function : usage variations - built-in functions as 
'callback' argument 
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing built-in functions and different language constructs as 'callback' 
argument
+*/
+
+echo "*** Testing array_filter() : usage variations - built-in functions as 
'callback' argument ***\n";
+
+$input = array(0, 1, -1, 10, 100, 1000, 'Hello', null);
+
+// using built-in function 'is_int' as 'callback'
+var_dump( array_filter($input, 'is_int') );
+
+// using built-in function 'chr' as 'callback'
+var_dump( array_filter($input, 'chr') );
+
+// using language construct 'echo' as 'callback'
+var_dump( array_filter($input, 'echo') );
+
+// using language construct 'exit' as 'callback' 
+var_dump( array_filter($input, 'exit') );
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - built-in functions as 
'callback' argument ***
+array(6) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+}
+array(8) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  string(5) "Hello"
+  [7]=>
+  NULL
+}
+
+Warning: array_filter() expects parameter 2 to be valid callback, string given 
in %s on line %d
+NULL
+
+Warning: array_filter() expects parameter 2 to be valid callback, string given 
in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - built-in functions as 
'callback' argument ***
+array(6) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+}
+array(8) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(-1)
+  [3]=>
+  int(10)
+  [4]=>
+  int(100)
+  [5]=>
+  int(1000)
+  [6]=>
+  unicode(5) "Hello"
+  [7]=>
+  NULL
+}
+
+Warning: array_filter() expects parameter 2 to be valid callback, Unicode 
string given in %s on line %d
+NULL
+
+Warning: array_filter() expects parameter 2 to be valid callback, Unicode 
string given in %s on line %d
+NULL
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_error.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_filter_error.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:55 2007
+++ php-src/ext/standard/tests/array/array_filter_error.phpt    Fri Oct 19 
18:22:55 2007
@@ -0,0 +1,62 @@
+--TEST--
+Test array_filter() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+echo "*** Testing array_filter() : error conditions ***\n";
+
+// zero arguments
+echo "-- Testing array_filter() function with Zero arguments --";
+var_dump( array_filter() );
+
+$input = array(0, 1, 2, 3, 5);
+/*  callback function
+ *  Prototype : bool odd(array $input)
+ *  Parameters : $input - array for which each elements should be checked into 
the function
+ *  Return Type : bool - true if element is odd and returns false otherwise
+ *  Description : Function takes array as input and checks for its each 
elements.
+*/
+function odd($input)
+{
+  return ($input % 2 != 0);
+}
+$extra_arg = 10;
+
+// with one more than the expected number of arguments
+echo "-- Testing array_filter() function with more than expected no. of 
arguments --";
+var_dump( array_filter($input, "odd", $extra_arg) );
+
+// with incorrect callback function
+echo "-- Testing array_filter() function with incorrect callback --";
+var_dump( array_filter($input, "even") );
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : error conditions ***
+-- Testing array_filter() function with Zero arguments --
+Warning: array_filter() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+-- Testing array_filter() function with more than expected no. of arguments --
+Warning: array_filter() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+-- Testing array_filter() function with incorrect callback --
+Warning: array_filter() expects parameter 2 to be valid callback, string given 
in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing array_filter() : error conditions ***
+-- Testing array_filter() function with Zero arguments --
+Warning: array_filter() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+-- Testing array_filter() function with more than expected no. of arguments --
+Warning: array_filter() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+-- Testing array_filter() function with incorrect callback --
+Warning: array_filter() expects parameter 2 to be valid callback, Unicode 
string given in %s on line %d
+NULL
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_filter_basic.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:56 2007
+++ php-src/ext/standard/tests/array/array_filter_basic.phpt    Fri Oct 19 
18:22:55 2007
@@ -0,0 +1,74 @@
+--TEST--
+Test array_filter() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+
+echo "*** Testing array_filter() : basic functionality ***\n";
+
+
+// Initialise all required variables
+$input = array(1, 2, 3, 0, -1);  // 0 will be considered as FALSE and removed 
in default callback
+
+/* Callback function
+ * Prototype : bool even(array $input)
+ * Parameters : $input - input array each element of which will be checked in 
function even()
+ * Return type : boolean - true if element is even and false otherwise
+ * Description : This function takes array as parameter and checks for each 
element of array.
+ *              It returns true if the element is even number else returns 
false
+ */
+function even($input)
+{
+  return ($input % 2 == 0);
+}
+
+// with all possible arguments
+var_dump( array_filter($input,"even") );
+
+// with default arguments
+var_dump( array_filter($input) );
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : basic functionality ***
+array(2) {
+  [1]=>
+  int(2)
+  [3]=>
+  int(0)
+}
+array(4) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [4]=>
+  int(-1)
+}
+Done
+--UEXPECTF--
+*** Testing array_filter() : basic functionality ***
+array(2) {
+  [1]=>
+  int(2)
+  [3]=>
+  int(0)
+}
+array(4) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [4]=>
+  int(-1)
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation1.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:56 2007
+++ php-src/ext/standard/tests/array/array_filter_variation1.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,290 @@
+--TEST--
+Test array_filter() function : usage variations - Unexpected values for 
'input' argument
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/* Passing different scalar and nonscalar values for 'input' argument
+*/
+echo "*** Testing array_filter() : usage variations - unexpected values for 
'input'***\n";
+
+/* Callback function
+ * Prototype : bool always_true(array $input)
+ * Parameters : array for which each elements needs to be used in function
+ * Return value : Returns true for each element
+ * Discription : function applied to each element of the passed array and 
returns true
+ */
+function always_true($input)
+{
+  return true;
+}
+
+
+// get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// class definition for object variable
+class MyClass
+{
+  public function __toString()
+  {
+    return "object";
+  }
+}
+
+// resource variable
+$fp = fopen(__FILE__, 'r');
+
+// different values for 'input' argument
+$input_values = array(
+
+        // int data
+/*1*/   0,
+        1,
+        12345,
+        -2345,
+
+        // float data
+/*5*/   10.5,
+        -10.5,
+        12.3456789000e10,
+        12.3456789000E-10,
+        .5,
+
+
+        // null data
+/*10*/  NULL,
+        null,
+
+        // boolean data
+/*12*/  true,
+        false,
+        TRUE,
+        FALSE,
+
+        // empty data
+/*16*/  "",
+        '',
+
+        // string data
+/*18*/  "string",
+        'string',
+
+        // object data
+/*20*/  new MyClass(),
+ 
+        // resource data
+        $fp,
+
+        // undefined data
+        @$undefined_var,
+
+        // unset data
+/*23*/  @$unset_var,
+);
+
+// loop through each element of the array for input
+for($count = 0; $count < count($input_values); $count++) {
+  echo "-- Iteration ".($count + 1)." --\n";
+  var_dump( array_filter($input_values[$count],"always_true") );
+};
+
+// closing resource
+fclose($fp);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - unexpected values for 
'input'***
+-- Iteration 1 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 2 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 3 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 4 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 5 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 6 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 7 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 8 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 9 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 10 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+-- Iteration 11 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+-- Iteration 12 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 13 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 14 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 15 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 16 --
+
+Warning: array_filter() expects parameter 1 to be array, string given in %s on 
line %d
+NULL
+-- Iteration 17 --
+
+Warning: array_filter() expects parameter 1 to be array, string given in %s on 
line %d
+NULL
+-- Iteration 18 --
+
+Warning: array_filter() expects parameter 1 to be array, string given in %s on 
line %d
+NULL
+-- Iteration 19 --
+
+Warning: array_filter() expects parameter 1 to be array, string given in %s on 
line %d
+NULL
+-- Iteration 20 --
+
+Warning: array_filter() expects parameter 1 to be array, object given in %s on 
line %d
+NULL
+-- Iteration 21 --
+
+Warning: array_filter() expects parameter 1 to be array, resource given in %s 
on line %d
+NULL
+-- Iteration 22 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+-- Iteration 23 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - unexpected values for 
'input'***
+-- Iteration 1 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 2 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 3 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 4 --
+
+Warning: array_filter() expects parameter 1 to be array, integer given in %s 
on line %d
+NULL
+-- Iteration 5 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 6 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 7 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 8 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 9 --
+
+Warning: array_filter() expects parameter 1 to be array, double given in %s on 
line %d
+NULL
+-- Iteration 10 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+-- Iteration 11 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+-- Iteration 12 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 13 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 14 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 15 --
+
+Warning: array_filter() expects parameter 1 to be array, boolean given in %s 
on line %d
+NULL
+-- Iteration 16 --
+
+Warning: array_filter() expects parameter 1 to be array, Unicode string given 
in %s on line %d
+NULL
+-- Iteration 17 --
+
+Warning: array_filter() expects parameter 1 to be array, Unicode string given 
in %s on line %d
+NULL
+-- Iteration 18 --
+
+Warning: array_filter() expects parameter 1 to be array, Unicode string given 
in %s on line %d
+NULL
+-- Iteration 19 --
+
+Warning: array_filter() expects parameter 1 to be array, Unicode string given 
in %s on line %d
+NULL
+-- Iteration 20 --
+
+Warning: array_filter() expects parameter 1 to be array, object given in %s on 
line %d
+NULL
+-- Iteration 21 --
+
+Warning: array_filter() expects parameter 1 to be array, resource given in %s 
on line %d
+NULL
+-- Iteration 22 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+-- Iteration 23 --
+
+Warning: array_filter() expects parameter 1 to be array, null given in %s on 
line %d
+NULL
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation2.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation2.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:56 2007
+++ php-src/ext/standard/tests/array/array_filter_variation2.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,271 @@
+--TEST--
+Test array_filter() function : usage variations - Unexpected values for 
'callback' function argument
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/* Passing different scalar and nonscalar values in place of 'callback' 
argument
+*/
+echo "*** Testing array_filter() : usage variations - unexpected values for 
'callback' function***\n";
+
+// Initialise variables
+$input = array('value1', 'value2', 'value3', 'value4');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// class definition for object variable
+class MyClass
+{
+  public function __toString()
+  {
+    return 'object';
+  }
+}
+
+// resource variable
+$fp = fopen(__FILE__, 'r');
+
+// different scalar and nonscalar values in place of callback function
+$values = array(
+
+        // int data
+/*1*/   0,
+        1,
+        12345,
+        -2345,
+
+        // float data
+/*5*/   10.5,
+        -10.5,
+        12.3456789000e10,
+        12.3456789000E-10,
+        .5,
+
+        // array data
+/*10*/  array(),
+        array(0),
+        array(1),
+        array(1, 2),
+        array('color' => 'red', 'item' => 'pen'),
+
+        // null data
+/*15*/  NULL,
+        null,
+
+        // boolean data
+/*17*/  true,
+        false,
+        TRUE,
+        FALSE,
+
+        // empty data
+/*21*/  "",
+        '',
+
+        // string data
+/*23*/  "string",
+        'string',
+
+        // object data
+/*25*/  new MyClass(),
+
+        // resource data
+        $fp,
+
+        // undefined data
+        @$undefined_var,
+
+        // unset data
+/*28*/  @$unset_var,
+);
+
+// loop through each element of the 'values' for callback
+for($count = 0; $count < count($values); $count++) {
+  echo "-- Iteration ".($count + 1)." --";
+  var_dump( array_filter($input, $values[$count]) );
+};
+
+// closing resource
+fclose($fp);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - unexpected values for 
'callback' function***
+-- Iteration 1 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 2 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 3 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 4 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 5 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 6 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 7 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 8 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 9 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 10 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 11 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 12 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 13 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 14 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 15 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+-- Iteration 16 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+-- Iteration 17 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 18 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 19 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 20 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 21 --
+Warning: array_filter() expects parameter 2 to be valid callback, string given 
in %s on line %d
+NULL
+-- Iteration 22 --
+Warning: array_filter() expects parameter 2 to be valid callback, string given 
in %s on line %d
+NULL
+-- Iteration 23 --
+Warning: array_filter() expects parameter 2 to be valid callback, string given 
in %s on line %d
+NULL
+-- Iteration 24 --
+Warning: array_filter() expects parameter 2 to be valid callback, string given 
in %s on line %d
+NULL
+-- Iteration 25 --
+Warning: array_filter() expects parameter 2 to be valid callback, object given 
in %s on line %d
+NULL
+-- Iteration 26 --
+Warning: array_filter() expects parameter 2 to be valid callback, resource 
given in %s on line %d
+NULL
+-- Iteration 27 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+-- Iteration 28 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - unexpected values for 
'callback' function***
+-- Iteration 1 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 2 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 3 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 4 --
+Warning: array_filter() expects parameter 2 to be valid callback, integer 
given in %s on line %d
+NULL
+-- Iteration 5 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 6 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 7 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 8 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 9 --
+Warning: array_filter() expects parameter 2 to be valid callback, double given 
in %s on line %d
+NULL
+-- Iteration 10 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 11 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 12 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 13 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 14 --
+Warning: array_filter() expects parameter 2 to be valid callback, array given 
in %s on line %d
+NULL
+-- Iteration 15 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+-- Iteration 16 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+-- Iteration 17 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 18 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 19 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 20 --
+Warning: array_filter() expects parameter 2 to be valid callback, boolean 
given in %s on line %d
+NULL
+-- Iteration 21 --
+Warning: array_filter() expects parameter 2 to be valid callback, Unicode 
string given in %s on line %d
+NULL
+-- Iteration 22 --
+Warning: array_filter() expects parameter 2 to be valid callback, Unicode 
string given in %s on line %d
+NULL
+-- Iteration 23 --
+Warning: array_filter() expects parameter 2 to be valid callback, Unicode 
string given in %s on line %d
+NULL
+-- Iteration 24 --
+Warning: array_filter() expects parameter 2 to be valid callback, Unicode 
string given in %s on line %d
+NULL
+-- Iteration 25 --
+Warning: array_filter() expects parameter 2 to be valid callback, object given 
in %s on line %d
+NULL
+-- Iteration 26 --
+Warning: array_filter() expects parameter 2 to be valid callback, resource 
given in %s on line %d
+NULL
+-- Iteration 27 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+-- Iteration 28 --
+Warning: array_filter() expects parameter 2 to be valid callback, null given 
in %s on line %d
+NULL
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation3.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation3.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:56 2007
+++ php-src/ext/standard/tests/array/array_filter_variation3.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,381 @@
+--TEST--
+Test array_filter() function : usage variations - Different types of array for 
'input' argument
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing different types of array as 'input' argument.
+*/
+
+// callback function returning always false
+function always_false($input)
+{
+  return false;
+}
+
+// callback function returning always true
+function always_true($input)
+{
+  return true;
+}
+
+echo "*** Testing array_filter() : usage variations - different types of array 
for 'input' argument***\n";
+
+// different types of 'input' array
+$input_values = array(
+  array(0, 1, 2, -1, 034, 0X4A),  // integer values
+  array(0.0, 1.2, 1.2e3, 1.2e-3),  // float values
+  array('value1', "value2", '', " ", ""),  // string values
+  array(true, false, TRUE, FALSE),  // bool values
+  array(null, NULL),  // null values
+  array(1 => 'one', 'zero' => 0, -2 => "value"), //associative array
+  array("one" => 1, null => 'null', 5.2 => "float", true => 1, "" => 'empty'), 
 // associative array with different keys
+  array(1 => 'one', 2, "key" => 'value')  // combinition of associative and 
non-associative array
+
+);
+
+// loop through each element of 'input' with default callback
+for($count = 0; $count < count($input_values); $count++)
+{
+  echo "-- Iteration ".($count + 1). " --\n";
+  var_dump( array_filter($input_values[$count]) );
+  var_dump( array_filter($input_values[$count], 'always_true') );
+  var_dump( array_filter($input_values[$count], 'always_false') );
+}
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variations - different types of array for 
'input' argument***
+-- Iteration 1 --
+array(5) {
+  [1]=>
+  int(1)
+  [2]=>
+  int(2)
+  [3]=>
+  int(-1)
+  [4]=>
+  int(28)
+  [5]=>
+  int(74)
+}
+array(6) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(2)
+  [3]=>
+  int(-1)
+  [4]=>
+  int(28)
+  [5]=>
+  int(74)
+}
+array(0) {
+}
+-- Iteration 2 --
+array(3) {
+  [1]=>
+  float(1.2)
+  [2]=>
+  float(1200)
+  [3]=>
+  float(0.0012)
+}
+array(4) {
+  [0]=>
+  float(0)
+  [1]=>
+  float(1.2)
+  [2]=>
+  float(1200)
+  [3]=>
+  float(0.0012)
+}
+array(0) {
+}
+-- Iteration 3 --
+array(3) {
+  [0]=>
+  string(6) "value1"
+  [1]=>
+  string(6) "value2"
+  [3]=>
+  string(1) " "
+}
+array(5) {
+  [0]=>
+  string(6) "value1"
+  [1]=>
+  string(6) "value2"
+  [2]=>
+  string(0) ""
+  [3]=>
+  string(1) " "
+  [4]=>
+  string(0) ""
+}
+array(0) {
+}
+-- Iteration 4 --
+array(2) {
+  [0]=>
+  bool(true)
+  [2]=>
+  bool(true)
+}
+array(4) {
+  [0]=>
+  bool(true)
+  [1]=>
+  bool(false)
+  [2]=>
+  bool(true)
+  [3]=>
+  bool(false)
+}
+array(0) {
+}
+-- Iteration 5 --
+array(0) {
+}
+array(2) {
+  [0]=>
+  NULL
+  [1]=>
+  NULL
+}
+array(0) {
+}
+-- Iteration 6 --
+array(2) {
+  [1]=>
+  string(3) "one"
+  [-2]=>
+  string(5) "value"
+}
+array(3) {
+  [1]=>
+  string(3) "one"
+  ["zero"]=>
+  int(0)
+  [-2]=>
+  string(5) "value"
+}
+array(0) {
+}
+-- Iteration 7 --
+array(4) {
+  ["one"]=>
+  int(1)
+  [""]=>
+  string(5) "empty"
+  [5]=>
+  string(5) "float"
+  [1]=>
+  int(1)
+}
+array(4) {
+  ["one"]=>
+  int(1)
+  [""]=>
+  string(5) "empty"
+  [5]=>
+  string(5) "float"
+  [1]=>
+  int(1)
+}
+array(0) {
+}
+-- Iteration 8 --
+array(3) {
+  [1]=>
+  string(3) "one"
+  [2]=>
+  int(2)
+  ["key"]=>
+  string(5) "value"
+}
+array(3) {
+  [1]=>
+  string(3) "one"
+  [2]=>
+  int(2)
+  ["key"]=>
+  string(5) "value"
+}
+array(0) {
+}
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variations - different types of array for 
'input' argument***
+-- Iteration 1 --
+array(5) {
+  [1]=>
+  int(1)
+  [2]=>
+  int(2)
+  [3]=>
+  int(-1)
+  [4]=>
+  int(28)
+  [5]=>
+  int(74)
+}
+array(6) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(1)
+  [2]=>
+  int(2)
+  [3]=>
+  int(-1)
+  [4]=>
+  int(28)
+  [5]=>
+  int(74)
+}
+array(0) {
+}
+-- Iteration 2 --
+array(3) {
+  [1]=>
+  float(1.2)
+  [2]=>
+  float(1200)
+  [3]=>
+  float(0.0012)
+}
+array(4) {
+  [0]=>
+  float(0)
+  [1]=>
+  float(1.2)
+  [2]=>
+  float(1200)
+  [3]=>
+  float(0.0012)
+}
+array(0) {
+}
+-- Iteration 3 --
+array(3) {
+  [0]=>
+  unicode(6) "value1"
+  [1]=>
+  unicode(6) "value2"
+  [3]=>
+  unicode(1) " "
+}
+array(5) {
+  [0]=>
+  unicode(6) "value1"
+  [1]=>
+  unicode(6) "value2"
+  [2]=>
+  unicode(0) ""
+  [3]=>
+  unicode(1) " "
+  [4]=>
+  unicode(0) ""
+}
+array(0) {
+}
+-- Iteration 4 --
+array(2) {
+  [0]=>
+  bool(true)
+  [2]=>
+  bool(true)
+}
+array(4) {
+  [0]=>
+  bool(true)
+  [1]=>
+  bool(false)
+  [2]=>
+  bool(true)
+  [3]=>
+  bool(false)
+}
+array(0) {
+}
+-- Iteration 5 --
+array(0) {
+}
+array(2) {
+  [0]=>
+  NULL
+  [1]=>
+  NULL
+}
+array(0) {
+}
+-- Iteration 6 --
+array(2) {
+  [1]=>
+  unicode(3) "one"
+  [-2]=>
+  unicode(5) "value"
+}
+array(3) {
+  [1]=>
+  unicode(3) "one"
+  [u"zero"]=>
+  int(0)
+  [-2]=>
+  unicode(5) "value"
+}
+array(0) {
+}
+-- Iteration 7 --
+array(4) {
+  [u"one"]=>
+  int(1)
+  [u""]=>
+  unicode(5) "empty"
+  [5]=>
+  unicode(5) "float"
+  [1]=>
+  int(1)
+}
+array(4) {
+  [u"one"]=>
+  int(1)
+  [u""]=>
+  unicode(5) "empty"
+  [5]=>
+  unicode(5) "float"
+  [1]=>
+  int(1)
+}
+array(0) {
+}
+-- Iteration 8 --
+array(3) {
+  [1]=>
+  unicode(3) "one"
+  [2]=>
+  int(2)
+  [u"key"]=>
+  unicode(5) "value"
+}
+array(3) {
+  [1]=>
+  unicode(3) "one"
+  [2]=>
+  int(2)
+  [u"key"]=>
+  unicode(5) "value"
+}
+array(0) {
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_filter_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_filter_variation4.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_filter_variation4.phpt:1.2
--- /dev/null   Fri Oct 19 18:22:56 2007
+++ php-src/ext/standard/tests/array/array_filter_variation4.phpt       Fri Oct 
19 18:22:55 2007
@@ -0,0 +1,134 @@
+--TEST--
+Test array_filter() function : usage variations - Different types of 
'callback' function
+--FILE--
+<?php
+/* Prototype  : array array_filter(array $input [, callback $callback])
+ * Description: Filters elements from the array via the callback. 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing different types of callback functions to array_filter()
+* with parameters and return
+* without parameter and with return
+* with parameter and without return
+* without parameter and without return
+*/
+
+echo "*** Testing array_filter() : usage variation - different 'callback' 
functions***\n";
+
+// Initialize variables
+$input = array(0, -1, 2, 3.4E-3, 'hello', "value", "key" => 4, 'null' => NULL);
+
+// callback function without parameters and with return value
+function callback1()
+{
+  return 1;
+}
+echo "-- Callback function without parameter and with return --\n";
+var_dump( array_filter($input, "callback1") );
+
+// callback function with parameter and without return value
+function callback2($input)
+{
+}
+echo "-- Callback funciton with parameter and without return --\n";
+var_dump( array_filter($input, "callback2") );
+
+
+// callback function without parameter and without return value
+function callback3()
+{
+}
+echo "-- Callback function without parameter and return --\n";
+var_dump( array_filter($input, "callback3") );
+
+// callback function with parameter and with return value
+function callback4($input)
+{
+  if($input > 0 ) { 
+    return true;
+  }
+  else {
+    return false;
+  }
+}
+echo "-- Callback function with parameter and return --\n";
+var_dump( array_filter($input, "callback4") );
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing array_filter() : usage variation - different 'callback' 
functions***
+-- Callback function without parameter and with return --
+array(8) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(-1)
+  [2]=>
+  int(2)
+  [3]=>
+  float(0.0034)
+  [4]=>
+  string(5) "hello"
+  [5]=>
+  string(5) "value"
+  ["key"]=>
+  int(4)
+  ["null"]=>
+  NULL
+}
+-- Callback funciton with parameter and without return --
+array(0) {
+}
+-- Callback function without parameter and return --
+array(0) {
+}
+-- Callback function with parameter and return --
+array(3) {
+  [2]=>
+  int(2)
+  [3]=>
+  float(0.0034)
+  ["key"]=>
+  int(4)
+}
+Done
+--UEXPECTF--
+*** Testing array_filter() : usage variation - different 'callback' 
functions***
+-- Callback function without parameter and with return --
+array(8) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(-1)
+  [2]=>
+  int(2)
+  [3]=>
+  float(0.0034)
+  [4]=>
+  unicode(5) "hello"
+  [5]=>
+  unicode(5) "value"
+  [u"key"]=>
+  int(4)
+  [u"null"]=>
+  NULL
+}
+-- Callback funciton with parameter and without return --
+array(0) {
+}
+-- Callback function without parameter and return --
+array(0) {
+}
+-- Callback function with parameter and return --
+array(3) {
+  [2]=>
+  int(2)
+  [3]=>
+  float(0.0034)
+  [u"key"]=>
+  int(4)
+}
+Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to