jmessa          Thu Feb 14 14:22:43 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/standard/tests/array   array_values_basic.phpt 
                                        array_values_variation2.phpt 
                                        array_values_variation4.phpt 
                                        array_values_variation5.phpt 
                                        array_values_variation1.phpt 
                                        array_values_variation6.phpt 
                                        array_values_variation3.phpt 
  Log:
  - New tests for array_values() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_values_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_values_basic.phpt
+++ php-src/ext/standard/tests/array/array_values_basic.phpt
--TEST--
Test array_values() function : basic functionality 
--FILE--
<?php
/* Prototype  : array array_values(array $input)
 * Description: Return just the values from the input array 
 * Source code: ext/standard/array.c
 */

/*
 * Test basic functionality of array_values()
 */

echo "*** Testing array_values() : basic functionality ***\n";


// Initialise all required variables
$input = array('zero', 'one', 'two', 'three' => 3, 10 => 'ten');

// Calling array_values() with all possible arguments
var_dump( array_values($input) );

echo "Done";
?>

--EXPECTF--
*** Testing array_values() : basic functionality ***
array(5) {
  [0]=>
  string(4) "zero"
  [1]=>
  string(3) "one"
  [2]=>
  string(3) "two"
  [3]=>
  int(3)
  [4]=>
  string(3) "ten"
}
Done
--UEXPECTF--
*** Testing array_values() : basic functionality ***
array(5) {
  [0]=>
  unicode(4) "zero"
  [1]=>
  unicode(3) "one"
  [2]=>
  unicode(3) "two"
  [3]=>
  int(3)
  [4]=>
  unicode(3) "ten"
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_values_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_values_variation2.phpt
+++ php-src/ext/standard/tests/array/array_values_variation2.phpt
--TEST--
Test array_values() function : usage variations - arrays of different data types
--FILE--
<?php
/* Prototype  : array array_values(array $input)
 * Description: Return just the values from the input array 
 * Source code: ext/standard/array.c
 */

/*
 * Pass arrays of different data types as $input argument to array_values() to 
test behaviour
 */

echo "*** Testing array_values() : usage variations ***\n";

//get an unset variable
$unset_var = 10;
unset ($unset_var);

// get a class
class classA
{
  public function __toString() {
    return "Class A object";
  }
}

// heredoc string
$heredoc = <<<EOT
hello world
EOT;

// get a resource variable
$fp = fopen(__FILE__, "r");

// arrays of different data types to be passed as $input
$inputs = array(

       // int data
/*1*/  'int' => array(
           0,
       1,
       12345,
       -2345,
       ),

       // float data
/*2*/  'float' => array(
       10.5,
       -10.5,
       12.3456789000e10,
       12.3456789000E-10,
       .5,
       ),

       // null data
/*3*/ 'null' => array(
       NULL,
       null,
       ),

       // boolean data
/*4*/ 'bool' => array(
       true,
       false,
       TRUE,
       FALSE,
       ),
       
       // empty data
/*5*/ 'empty string' => array(
       "",
       '',
       ),
       
/*6*/ 'empty array' => array(
       ),

       // string data
/*7*/ 'string' => array(
       "string",
       'string',
       $heredoc,
       ),
       
       // object data
/*8*/ 'object' => array(
       new classA(),
       ),

       // undefined data
/*9*/ 'undefined' => array(
       @$undefined_var,
       ),

       // unset data
/*10*/ 'unset' => array(
       @$unset_var,
       ),

       // resource variable
/*11*/ 'resource' => array(
       $fp
       ),
);

// loop through each element of $inputs to check the behavior of array_values()
$iterator = 1;
foreach($inputs as $key => $input) {
  echo "\n-- Iteration $iterator: $key data --\n";
  var_dump( array_values($input) );
  $iterator++;
};

fclose($fp);

echo "Done";
?>

--EXPECTF--
*** Testing array_values() : usage variations ***

-- Iteration 1: int data --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(12345)
  [3]=>
  int(-2345)
}

-- Iteration 2: float data --
array(5) {
  [0]=>
  float(10.5)
  [1]=>
  float(-10.5)
  [2]=>
  float(123456789000)
  [3]=>
  float(1.23456789E-9)
  [4]=>
  float(0.5)
}

-- Iteration 3: null data --
array(2) {
  [0]=>
  NULL
  [1]=>
  NULL
}

-- Iteration 4: bool data --
array(4) {
  [0]=>
  bool(true)
  [1]=>
  bool(false)
  [2]=>
  bool(true)
  [3]=>
  bool(false)
}

-- Iteration 5: empty string data --
array(2) {
  [0]=>
  string(0) ""
  [1]=>
  string(0) ""
}

-- Iteration 6: empty array data --
array(0) {
}

-- Iteration 7: string data --
array(3) {
  [0]=>
  string(6) "string"
  [1]=>
  string(6) "string"
  [2]=>
  string(11) "hello world"
}

-- Iteration 8: object data --
array(1) {
  [0]=>
  object(classA)#%d (0) {
  }
}

-- Iteration 9: undefined data --
array(1) {
  [0]=>
  NULL
}

-- Iteration 10: unset data --
array(1) {
  [0]=>
  NULL
}

-- Iteration 11: resource data --
array(1) {
  [0]=>
  resource(%d) of type (stream)
}
Done
--UEXPECTF--
*** Testing array_values() : usage variations ***

-- Iteration 1: int data --
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(12345)
  [3]=>
  int(-2345)
}

-- Iteration 2: float data --
array(5) {
  [0]=>
  float(10.5)
  [1]=>
  float(-10.5)
  [2]=>
  float(123456789000)
  [3]=>
  float(1.23456789E-9)
  [4]=>
  float(0.5)
}

-- Iteration 3: null data --
array(2) {
  [0]=>
  NULL
  [1]=>
  NULL
}

-- Iteration 4: bool data --
array(4) {
  [0]=>
  bool(true)
  [1]=>
  bool(false)
  [2]=>
  bool(true)
  [3]=>
  bool(false)
}

-- Iteration 5: empty string data --
array(2) {
  [0]=>
  unicode(0) ""
  [1]=>
  unicode(0) ""
}

-- Iteration 6: empty array data --
array(0) {
}

-- Iteration 7: string data --
array(3) {
  [0]=>
  unicode(6) "string"
  [1]=>
  unicode(6) "string"
  [2]=>
  unicode(11) "hello world"
}

-- Iteration 8: object data --
array(1) {
  [0]=>
  object(classA)#%d (0) {
  }
}

-- Iteration 9: undefined data --
array(1) {
  [0]=>
  NULL
}

-- Iteration 10: unset data --
array(1) {
  [0]=>
  NULL
}

-- Iteration 11: resource data --
array(1) {
  [0]=>
  resource(%d) of type (stream)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_values_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_values_variation4.phpt
+++ php-src/ext/standard/tests/array/array_values_variation4.phpt
--TEST--
Test array_values() function : usage variations - multi-dimensional arrays
--FILE--
<?php
/* Prototype  : array array_values(array $input)
 * Description: Return just the values from the input array 
 * Source code: ext/standard/array.c
 */

/*
 * Test array_values when:
 * 1. Passed a two-dimensional array as $input argument
 * 2. Passed a sub-array as $input argument
 * 3. Passed an infinitely recursive multi-dimensional array
 */

echo "*** Testing array_values() : usage variations ***\n";

$input = array ('zero' => 'zero', 'un' => 'one', 'sub' => array (1, 2, 3));

echo "\n-- Array values of a two-dimensional array --\n";
var_dump(array_values($input));

echo "\n-- Array values of a sub-array --\n";
var_dump(array_values($input['sub']));

// get an infinitely recursive array
$input[] = &$input;
echo "\n-- Array values of an infinitely recursive array --\n";
var_dump(array_values($input));

echo "Done";
?>

--EXPECTF--
*** Testing array_values() : usage variations ***

-- Array values of a two-dimensional array --
array(3) {
  [0]=>
  string(4) "zero"
  [1]=>
  string(3) "one"
  [2]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
}

-- Array values of a sub-array --
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

-- Array values of an infinitely recursive array --
array(4) {
  [0]=>
  string(4) "zero"
  [1]=>
  string(3) "one"
  [2]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
  [3]=>
  &array(4) {
    ["zero"]=>
    string(4) "zero"
    ["un"]=>
    string(3) "one"
    ["sub"]=>
    array(3) {
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
    }
    [0]=>
    &array(4) {
      ["zero"]=>
      string(4) "zero"
      ["un"]=>
      string(3) "one"
      ["sub"]=>
      array(3) {
        [0]=>
        int(1)
        [1]=>
        int(2)
        [2]=>
        int(3)
      }
      [0]=>
      *RECURSION*
    }
  }
}
Done
--UEXPECTF--
*** Testing array_values() : usage variations ***

-- Array values of a two-dimensional array --
array(3) {
  [0]=>
  unicode(4) "zero"
  [1]=>
  unicode(3) "one"
  [2]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
}

-- Array values of a sub-array --
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

-- Array values of an infinitely recursive array --
array(4) {
  [0]=>
  unicode(4) "zero"
  [1]=>
  unicode(3) "one"
  [2]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
  [3]=>
  &array(4) {
    [u"zero"]=>
    unicode(4) "zero"
    [u"un"]=>
    unicode(3) "one"
    [u"sub"]=>
    array(3) {
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
    }
    [0]=>
    &array(4) {
      [u"zero"]=>
      unicode(4) "zero"
      [u"un"]=>
      unicode(3) "one"
      [u"sub"]=>
      array(3) {
        [0]=>
        int(1)
        [1]=>
        int(2)
        [2]=>
        int(3)
      }
      [0]=>
      *RECURSION*
    }
  }
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_values_variation5.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_values_variation5.phpt
+++ php-src/ext/standard/tests/array/array_values_variation5.phpt
--TEST--
Test array_values() function : usage variations - internal array pointer
--FILE--
<?php
/* Prototype  : array array_values(array $input)
 * Description: Return just the values from the input array 
 * Source code: ext/standard/array.c
 */

/*
 * Test the position of the internal array pointer after a call to array_values
 */

echo "*** Testing array_values() : usage variations ***\n";

$input = array ('one' => 'un', 'two' => 'deux', 'three' => 'trois');

echo "\n-- Call array_values() --\n";
var_dump($result = array_values($input));

echo "-- Position of Internal Pointer in Result: --\n";
echo key($result) . " => " . current($result) . "\n";
echo "\n-- Position of Internal Pointer in Original Array: --\n";
echo key($input) . " => " . current ($input) . "\n";

echo "Done";
?>

--EXPECTF--
*** Testing array_values() : usage variations ***

-- Call array_values() --
array(3) {
  [0]=>
  string(2) "un"
  [1]=>
  string(4) "deux"
  [2]=>
  string(5) "trois"
}
-- Position of Internal Pointer in Result: --
0 => un

-- Position of Internal Pointer in Original Array: --
one => un
Done
--UEXPECTF--
*** Testing array_values() : usage variations ***

-- Call array_values() --
array(3) {
  [0]=>
  unicode(2) "un"
  [1]=>
  unicode(4) "deux"
  [2]=>
  unicode(5) "trois"
}
-- Position of Internal Pointer in Result: --
0 => un

-- Position of Internal Pointer in Original Array: --
one => un
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_values_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_values_variation1.phpt
+++ php-src/ext/standard/tests/array/array_values_variation1.phpt
--TEST--
Test array_values() function : usage variations - Pass different data types as 
$input arg
--FILE--
<?php
/* Prototype  : array array_values(array $input)
 * Description: Return just the values from the input array 
 * Source code: ext/standard/array.c
 */

/*
 * Pass different data types as $input argument to array_values() to test 
behaviour
 */

echo "*** Testing array_values() : usage variations ***\n";

//get an unset variable
$unset_var = 10;
unset ($unset_var);

// get a class
class classA
{
  public function __toString() {
    return "Class A object";
  }
}

// heredoc string
$heredoc = <<<EOT
hello world
EOT;

// get a resource variable
$fp = fopen(__FILE__, "r");

// unexpected values to be passed to $input argument
$inputs = 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*/ "",
       '',
       array(),

       // string data
/*19*/ "string",
       'string',
       $heredoc,
       
       // object data
/*22*/ new classA(),

       // undefined data
/*23*/ @$undefined_var,

       // unset data
/*24*/ @$unset_var,

       // resource variable
/*25*/ $fp
);

// loop through each element of $inputs to check the behavior of array_values()
$iterator = 1;
foreach($inputs as $input) {
  echo "\n-- Iteration $iterator --\n";
  var_dump( array_values($input) );
  $iterator++;
};

fclose($fp);

echo "Done";
?>

--EXPECTF--
*** Testing array_values() : usage variations ***

-- Iteration 1 --

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

-- Iteration 2 --

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

-- Iteration 3 --

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

-- Iteration 4 --

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

-- Iteration 5 --

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

-- Iteration 6 --

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

-- Iteration 7 --

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

-- Iteration 8 --

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

-- Iteration 9 --

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

-- Iteration 10 --

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

-- Iteration 11 --

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

-- Iteration 12 --

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

-- Iteration 13 --

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

-- Iteration 14 --

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

-- Iteration 15 --

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

-- Iteration 16 --

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

-- Iteration 17 --

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

-- Iteration 18 --
array(0) {
}

-- Iteration 19 --

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

-- Iteration 20 --

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

-- Iteration 21 --

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

-- Iteration 22 --

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

-- Iteration 23 --

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

-- Iteration 24 --

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

-- Iteration 25 --

Warning: array_values() expects parameter 1 to be array, resource given in %s 
on line %d
NULL
Done
--UEXPECTF--
*** Testing array_values() : usage variations ***

-- Iteration 1 --

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

-- Iteration 2 --

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

-- Iteration 3 --

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

-- Iteration 4 --

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

-- Iteration 5 --

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

-- Iteration 6 --

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

-- Iteration 7 --

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

-- Iteration 8 --

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

-- Iteration 9 --

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

-- Iteration 10 --

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

-- Iteration 11 --

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

-- Iteration 12 --

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

-- Iteration 13 --

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

-- Iteration 14 --

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

-- Iteration 15 --

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

-- Iteration 16 --

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

-- Iteration 17 --

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

-- Iteration 18 --
array(0) {
}

-- Iteration 19 --

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

-- Iteration 20 --

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

-- Iteration 21 --

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

-- Iteration 22 --

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

-- Iteration 23 --

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

-- Iteration 24 --

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

-- Iteration 25 --

Warning: array_values() expects parameter 1 to be array, resource given in %s 
on line %d
NULL
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_values_variation6.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_values_variation6.phpt
+++ php-src/ext/standard/tests/array/array_values_variation6.phpt
--TEST--
Test array_values() function : usage variations - Referenced variables
--FILE--
<?php
/* Prototype  : array array_values(array $input)
 * Description: Return just the values from the input array 
 * Source code: ext/standard/array.c
 */

/*
 * Test array_values() when:
 * 1. Passed an array made up of referenced variables
 * 2. Passed an array by reference
 */

echo "*** Testing array_values() : usage variations ***\n";

$val1 = 'one';
$val2 = 'two';
$val3 = 'three';

echo "\n-- \$input is an array made up of referenced variables: --\n";
$input = array(&$val1, &$val2, &$val3);
var_dump($result1 = array_values($input));

echo "Change \$val2 and check result of array_values():\n";
$val2 = 'deux';
var_dump($result1);

echo "\n-- Pass \$input argument by reference --\n";
$array = array(1, 2, 3);
var_dump($result2 = array_values(&$array));

echo "Done";
?>

--EXPECTF--
Strict Standards: Call-time pass-by-reference has been deprecated in %s on line 
%d
*** Testing array_values() : usage variations ***

-- $input is an array made up of referenced variables: --
array(3) {
  [0]=>
  &string(3) "one"
  [1]=>
  &string(3) "two"
  [2]=>
  &string(5) "three"
}
Change $val2 and check result of array_values():
array(3) {
  [0]=>
  &string(3) "one"
  [1]=>
  &string(4) "deux"
  [2]=>
  &string(5) "three"
}

-- Pass $input argument by reference --
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
Done
--UEXPECTF--
Strict Standards: Call-time pass-by-reference has been deprecated in %s on line 
%d
*** Testing array_values() : usage variations ***

-- $input is an array made up of referenced variables: --
array(3) {
  [0]=>
  &unicode(3) "one"
  [1]=>
  &unicode(3) "two"
  [2]=>
  &unicode(5) "three"
}
Change $val2 and check result of array_values():
array(3) {
  [0]=>
  &unicode(3) "one"
  [1]=>
  &unicode(4) "deux"
  [2]=>
  &unicode(5) "three"
}

-- Pass $input argument by reference --
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_values_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_values_variation3.phpt
+++ php-src/ext/standard/tests/array/array_values_variation3.phpt
--TEST--
Test array_values() function : usage variations - array keys different data 
types
--FILE--
<?php
/* Prototype  : array array_values(array $input)
 * Description: Return just the values from the input array 
 * Source code: ext/standard/array.c
 */

/*
 * Pass arrays where the keys are different data types as $input argument
 * to array_values() to test behaviour
 */

echo "*** Testing array_values() : usage variations ***\n";

//get an unset variable
$unset_var = 10;
unset ($unset_var);

// heredoc string
$heredoc = <<<EOT
hello world
EOT;

// unexpected values to be passed as $input
$inputs = array(

       // int data
/*1*/  'int' => array(
       0 => 'zero',
       1 => 'one',
       12345 => 'positive',
       -2345 => 'negative',
       ),

       // float data
/*2*/  'float' => array(
       10.5 => 'positive',
       -10.5 => 'negative',
       .5 => 'half',
       ),
       
/*3*/  'extreme floats' => array(
       12.3456789000e10 => 'large',
       12.3456789000E-10 => 'small',
       ),

       // null data
/*4*/ 'null uppercase' => array(
       NULL => 'null 1',
       ), 
       
/*5*/  'null lowercase' => array(
       null => 'null 2',
       ),

       // boolean data
/*6*/ 'bool lowercase' => array(
       true => 'lowert',
       false => 'lowerf',
       ),
       
/*7*/  'bool uppercase' => array(
       TRUE => 'uppert',
       FALSE => 'upperf',
       ),
       
       // empty data
/*8*/ 'empty double quotes' => array(
       "" => 'emptyd',
       ),
       
/*9*/  'empty single quotes' => array(
       '' => 'emptys',
       ),

       // string data
/*10*/ 'string' => array(
       "stringd" => 'stringd',
       'strings' => 'strings',
       $heredoc => 'stringh',
       ),

       // undefined data
/*11*/ 'undefined' => array(
       @$undefined_var => 'undefined',
       ),

       // unset data
/*12*/ 'unset' => array(
       @$unset_var => 'unset',
       ),
);

// loop through each element of $inputs to check the behavior of array_values()
$iterator = 1;
foreach($inputs as $key => $input) {
  echo "\n-- Iteration $iterator: $key data --\n";
  var_dump( array_values($input) );
  $iterator++;
};
echo "Done";
?>

--EXPECTF--
*** Testing array_values() : usage variations ***

-- Iteration 1: int data --
array(4) {
  [0]=>
  string(4) "zero"
  [1]=>
  string(3) "one"
  [2]=>
  string(8) "positive"
  [3]=>
  string(8) "negative"
}

-- Iteration 2: float data --
array(3) {
  [0]=>
  string(8) "positive"
  [1]=>
  string(8) "negative"
  [2]=>
  string(4) "half"
}

-- Iteration 3: extreme floats data --
array(2) {
  [0]=>
  string(5) "large"
  [1]=>
  string(5) "small"
}

-- Iteration 4: null uppercase data --
array(1) {
  [0]=>
  string(6) "null 1"
}

-- Iteration 5: null lowercase data --
array(1) {
  [0]=>
  string(6) "null 2"
}

-- Iteration 6: bool lowercase data --
array(2) {
  [0]=>
  string(6) "lowert"
  [1]=>
  string(6) "lowerf"
}

-- Iteration 7: bool uppercase data --
array(2) {
  [0]=>
  string(6) "uppert"
  [1]=>
  string(6) "upperf"
}

-- Iteration 8: empty double quotes data --
array(1) {
  [0]=>
  string(6) "emptyd"
}

-- Iteration 9: empty single quotes data --
array(1) {
  [0]=>
  string(6) "emptys"
}

-- Iteration 10: string data --
array(3) {
  [0]=>
  string(7) "stringd"
  [1]=>
  string(7) "strings"
  [2]=>
  string(7) "stringh"
}

-- Iteration 11: undefined data --
array(1) {
  [0]=>
  string(9) "undefined"
}

-- Iteration 12: unset data --
array(1) {
  [0]=>
  string(5) "unset"
}
Done
--UEXPECTF--
*** Testing array_values() : usage variations ***

-- Iteration 1: int data --
array(4) {
  [0]=>
  unicode(4) "zero"
  [1]=>
  unicode(3) "one"
  [2]=>
  unicode(8) "positive"
  [3]=>
  unicode(8) "negative"
}

-- Iteration 2: float data --
array(3) {
  [0]=>
  unicode(8) "positive"
  [1]=>
  unicode(8) "negative"
  [2]=>
  unicode(4) "half"
}

-- Iteration 3: extreme floats data --
array(2) {
  [0]=>
  unicode(5) "large"
  [1]=>
  unicode(5) "small"
}

-- Iteration 4: null uppercase data --
array(1) {
  [0]=>
  unicode(6) "null 1"
}

-- Iteration 5: null lowercase data --
array(1) {
  [0]=>
  unicode(6) "null 2"
}

-- Iteration 6: bool lowercase data --
array(2) {
  [0]=>
  unicode(6) "lowert"
  [1]=>
  unicode(6) "lowerf"
}

-- Iteration 7: bool uppercase data --
array(2) {
  [0]=>
  unicode(6) "uppert"
  [1]=>
  unicode(6) "upperf"
}

-- Iteration 8: empty double quotes data --
array(1) {
  [0]=>
  unicode(6) "emptyd"
}

-- Iteration 9: empty single quotes data --
array(1) {
  [0]=>
  unicode(6) "emptys"
}

-- Iteration 10: string data --
array(3) {
  [0]=>
  unicode(7) "stringd"
  [1]=>
  unicode(7) "strings"
  [2]=>
  unicode(7) "stringh"
}

-- Iteration 11: undefined data --
array(1) {
  [0]=>
  unicode(9) "undefined"
}

-- Iteration 12: unset data --
array(1) {
  [0]=>
  unicode(5) "unset"
}
Done
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to