tony2001                Fri Jul 13 16:47:39 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/array   array_keys_error.phpt 
                                        array_keys_variation_001.phpt 
                                        array_keys_variation_002_64bit.phpt 
                                        array_keys_variation_002.phpt 
                                        array_keys_variation_003.phpt 
                                        array_keys_variation_004.phpt 
                                        array_keys_variation_005.phpt 
  Log:
  MFH: split the test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_keys_error.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_keys_error.phpt
+++ php-src/ext/standard/tests/array/array_keys_error.phpt
--TEST--
Test array_keys() function (error conditions)
--FILE--
<?php

echo "\n*** Testing error conditions ***";
var_dump(array_keys(100));
var_dump(array_keys("string"));
var_dump(array_keys(new stdclass));  // object
var_dump(array_keys());  // Zero arguments
var_dump(array_keys(array(), "", TRUE, 100));  // args > expected
var_dump(array_keys(array(1,2,3, array() => array())));  // (W)illegal offset

echo "Done\n";
?>
--EXPECTF--
*** Testing error conditions ***
Warning: array_keys() expects parameter 1 to be array, integer given in %s on 
line %d
NULL

Warning: array_keys() expects parameter 1 to be array, string given in %s on 
line %d
NULL

Warning: array_keys() expects parameter 1 to be array, object given in %s on 
line %d
NULL

Warning: array_keys() expects at least 1 parameter, 0 given in %s on line %d
NULL

Warning: array_keys() expects at most 3 parameters, 4 given in %s on line %d
NULL

Warning: Illegal offset type in %s on line %d
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
Done
--UEXPECTF--
*** Testing error conditions ***
Warning: array_keys() expects parameter 1 to be array, integer given in %s on 
line %d
NULL

Warning: array_keys() expects parameter 1 to be array, Unicode string given in 
%s on line %d
NULL

Warning: array_keys() expects parameter 1 to be array, object given in %s on 
line %d
NULL

Warning: array_keys() expects at least 1 parameter, 0 given in %s on line %d
NULL

Warning: array_keys() expects at most 3 parameters, 4 given in %s on line %d
NULL

Warning: Illegal offset type in %s on line %d
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_keys_variation_001.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_keys_variation_001.phpt
+++ php-src/ext/standard/tests/array/array_keys_variation_001.phpt
--TEST--
Test array_keys() function (variation - 1)
--FILE--
<?php

echo "\n*** Testing array_keys() on various arrays ***";
$arrays = array(
  array(), 
  array(0),
  array( array() ), 
  array("Hello" => "World"), 
  array("" => ""),  
  array(1,2,3, "d" => array(4,6, "d")),
  array("a" => 1, "b" => 2, "c" =>3, "d" => array()),
  array(0 => 0, 1 => 1, 2 => 2, 3 => 3),  
  array(0.001=>3.000, 1.002=>2, 1.999=>3, "a"=>3, 3=>5, "5"=>3.000),
  array(TRUE => TRUE, FALSE => FALSE, NULL => NULL, "\x000", "\000"),
  array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ),
  array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(),""=>"" )
);

$i = 0;
/* loop through to test array_keys() with different arrays */
foreach ($arrays as $array) {
  echo "\n-- Iteration $i --\n";
  var_dump(array_keys($array)); 
  $i++;
}

echo "Done\n";
?>
--EXPECTF--
*** Testing array_keys() on various arrays ***
-- Iteration 0 --
array(0) {
}

-- Iteration 1 --
array(1) {
  [0]=>
  int(0)
}

-- Iteration 2 --
array(1) {
  [0]=>
  int(0)
}

-- Iteration 3 --
array(1) {
  [0]=>
  string(5) "Hello"
}

-- Iteration 4 --
array(1) {
  [0]=>
  string(0) ""
}

-- Iteration 5 --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  string(1) "d"
}

-- Iteration 6 --
array(4) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(1) "c"
  [3]=>
  string(1) "d"
}

-- Iteration 7 --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}

-- Iteration 8 --
array(5) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  string(1) "a"
  [3]=>
  int(3)
  [4]=>
  int(5)
}

-- Iteration 9 --
array(5) {
  [0]=>
  int(1)
  [1]=>
  int(0)
  [2]=>
  string(0) ""
  [3]=>
  int(2)
  [4]=>
  int(3)
}

-- Iteration 10 --
array(3) {
  [0]=>
  string(1) "a"
  [1]=>
  string(2) "ab"
  [2]=>
  string(2) "cd"
}

-- Iteration 11 --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  string(0) ""
}
Done
--UEXPECTF--
*** Testing array_keys() on various arrays ***
-- Iteration 0 --
array(0) {
}

-- Iteration 1 --
array(1) {
  [0]=>
  int(0)
}

-- Iteration 2 --
array(1) {
  [0]=>
  int(0)
}

-- Iteration 3 --
array(1) {
  [0]=>
  unicode(5) "Hello"
}

-- Iteration 4 --
array(1) {
  [0]=>
  unicode(0) ""
}

-- Iteration 5 --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  unicode(1) "d"
}

-- Iteration 6 --
array(4) {
  [0]=>
  unicode(1) "a"
  [1]=>
  unicode(1) "b"
  [2]=>
  unicode(1) "c"
  [3]=>
  unicode(1) "d"
}

-- Iteration 7 --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}

-- Iteration 8 --
array(5) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  unicode(1) "a"
  [3]=>
  int(3)
  [4]=>
  int(5)
}

-- Iteration 9 --
array(5) {
  [0]=>
  int(1)
  [1]=>
  int(0)
  [2]=>
  unicode(0) ""
  [3]=>
  int(2)
  [4]=>
  int(3)
}

-- Iteration 10 --
array(3) {
  [0]=>
  unicode(1) "a"
  [1]=>
  unicode(2) "ab"
  [2]=>
  unicode(2) "cd"
}

-- Iteration 11 --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  unicode(0) ""
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_keys_variation_002_64bit.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_keys_variation_002_64bit.phpt
+++ php-src/ext/standard/tests/array/array_keys_variation_002_64bit.phpt
--TEST--
Test array_keys() function (variation - 2)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php

echo "\n*** Testing array_keys() on range of values ***\n";
$arr_range = array(
  2147483647 => 1,
  2147483648 => 2,
  -2147483647 => 3, 
  -2147483648 => 4,
  -2147483649 => 5,
  -0 => 6,
  0 => 7
);
var_dump(array_keys($arr_range));

echo "\n*** Testing array_keys() on an array created on the fly ***\n";
var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3)));
var_dump(array_keys(array()));  // null array

echo "Done\n";
?>
--EXPECTF--
*** Testing array_keys() on range of values ***
array(6) {
  [0]=>
  int(2147483647)
  [1]=>
  int(2147483648)
  [2]=>
  int(-2147483647)
  [3]=>
  int(-2147483648)
  [4]=>
  int(-2147483649)
  [5]=>
  int(0)
}

*** Testing array_keys() on an array created on the fly ***
array(3) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(1) "c"
}
array(0) {
}
Done
--UEXPECTF--
*** Testing array_keys() on range of values ***
array(6) {
  [0]=>
  int(2147483647)
  [1]=>
  int(2147483648)
  [2]=>
  int(-2147483647)
  [3]=>
  int(-2147483648)
  [4]=>
  int(-2147483649)
  [5]=>
  int(0)
}

*** Testing array_keys() on an array created on the fly ***
array(3) {
  [0]=>
  unicode(1) "a"
  [1]=>
  unicode(1) "b"
  [2]=>
  unicode(1) "c"
}
array(0) {
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_keys_variation_002.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_keys_variation_002.phpt
+++ php-src/ext/standard/tests/array/array_keys_variation_002.phpt
--TEST--
Test array_keys() function (variation - 2)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php

echo "\n*** Testing array_keys() on range of values ***\n";
$arr_range = array(
  2147483647 => 1,
  2147483648 => 2,
  -2147483647 => 3, 
  -2147483648 => 4,
  -2147483649 => 5,
  -0 => 6,
  0 => 7
);
var_dump(array_keys($arr_range));

echo "\n*** Testing array_keys() on an array created on the fly ***\n";
var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3)));
var_dump(array_keys(array()));  // null array

echo "Done\n";
?>
--EXPECTF--
*** Testing array_keys() on range of values ***
array(4) {
  [0]=>
  int(2147483647)
  [1]=>
  int(-2147483648)
  [2]=>
  int(-2147483647)
  [3]=>
  int(0)
}

*** Testing array_keys() on an array created on the fly ***
array(3) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(1) "c"
}
array(0) {
}
Done
--UEXPECTF--
*** Testing array_keys() on range of values ***
array(4) {
  [0]=>
  int(2147483647)
  [1]=>
  int(-2147483648)
  [2]=>
  int(-2147483647)
  [3]=>
  int(0)
}

*** Testing array_keys() on an array created on the fly ***
array(3) {
  [0]=>
  unicode(1) "a"
  [1]=>
  unicode(1) "b"
  [2]=>
  unicode(1) "c"
}
array(0) {
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_keys_variation_003.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_keys_variation_003.phpt
+++ php-src/ext/standard/tests/array/array_keys_variation_003.phpt
--TEST--
Test array_keys() function (variation - 3)
--FILE--
<?php

echo "*** Testing array_keys() on all the types other than arrays ***\n";
$types_arr = array(
  TRUE => TRUE,
  FALSE => FALSE,
  1 => 1,
  0 => 0,
  -1 => -1, 
  "1" => "1",
  "0" => "0",
  "-1" => "-1",
  NULL,
  array(),
  "php" => "php",
  "" => ""
);
$values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1",  NULL, array(), "php", 
"");
foreach ($values as $value){
  var_dump(array_keys($types_arr, $value)); 
}

echo "Done\n";
?>
--EXPECTF--
*** Testing array_keys() on all the types other than arrays ***
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(-1)
  [2]=>
  string(3) "php"
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  string(0) ""
}
array(1) {
  [0]=>
  int(1)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(2)
  [2]=>
  string(3) "php"
  [3]=>
  string(0) ""
}
array(1) {
  [0]=>
  int(-1)
}
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(0)
}
array(1) {
  [0]=>
  int(-1)
}
array(3) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  string(0) ""
}
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(1) {
  [0]=>
  string(3) "php"
}
array(2) {
  [0]=>
  int(2)
  [1]=>
  string(0) ""
}
Done
--UEXPECTF--
*** Testing array_keys() on all the types other than arrays ***
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(-1)
  [2]=>
  unicode(3) "php"
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  unicode(0) ""
}
array(1) {
  [0]=>
  int(1)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(2)
  [2]=>
  unicode(3) "php"
  [3]=>
  unicode(0) ""
}
array(1) {
  [0]=>
  int(-1)
}
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(0)
}
array(1) {
  [0]=>
  int(-1)
}
array(3) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  unicode(0) ""
}
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(1) {
  [0]=>
  unicode(3) "php"
}
array(2) {
  [0]=>
  int(2)
  [1]=>
  unicode(0) ""
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_keys_variation_004.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_keys_variation_004.phpt
+++ php-src/ext/standard/tests/array/array_keys_variation_004.phpt
--TEST--
Test array_keys() function (variation - 4)
--FILE--
<?php

echo "*** Testing array_keys() on all the types other than arrays ***\n";
$types_arr = array(
  TRUE => TRUE,
  FALSE => FALSE,
  1 => 1,
  0 => 0,
  -1 => -1, 
  "1" => "1",
  "0" => "0",
  "-1" => "-1",
  NULL,
  array(),
  "php" => "php",
  "" => ""
);
$values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1",  NULL, array(), "php", 
"");
foreach ($values as $value){
  var_dump(array_keys($types_arr, $value, TRUE));
}

echo "Done\n";
?>
--EXPECTF--
*** Testing array_keys() on all the types other than arrays ***
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(0)
}
array(1) {
  [0]=>
  int(-1)
}
array(1) {
  [0]=>
  int(2)
}
array(1) {
  [0]=>
  int(3)
}
array(1) {
  [0]=>
  string(3) "php"
}
array(1) {
  [0]=>
  string(0) ""
}
Done
--UEXPECTF--
*** Testing array_keys() on all the types other than arrays ***
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(0)
}
array(1) {
  [0]=>
  int(-1)
}
array(1) {
  [0]=>
  int(2)
}
array(1) {
  [0]=>
  int(3)
}
array(1) {
  [0]=>
  unicode(3) "php"
}
array(1) {
  [0]=>
  unicode(0) ""
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_keys_variation_005.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_keys_variation_005.phpt
+++ php-src/ext/standard/tests/array/array_keys_variation_005.phpt
--TEST--
Test array_keys() function (variation - 5)
--FILE--
<?php

echo "\n*** Testing array_keys() with resource type ***\n";
$resource1 = fopen( __FILE__, "r");
$resource2 = opendir( "." );

/* creating an array with resource types as elements */
$arr_resource = array($resource1, $resource2); 

var_dump(array_keys($arr_resource, $resource1));  // loose type checking 
var_dump(array_keys($arr_resource, $resource1, TRUE));  // strict type checking
var_dump(array_keys($arr_resource, $resource2));  // loose type checking
var_dump(array_keys($arr_resource, $resource2, TRUE));  // strict type checking

/* Closing the resource handles */
fclose( $resource1 );
closedir( $resource2 );

?>
--EXPECTF--
*** Testing array_keys() with resource type ***
array(1) {
  [0]=>
  int(0)
}
array(1) {
  [0]=>
  int(0)
}
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(1)
}

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

Reply via email to