nicholsr                Thu Dec 20 11:18:08 2007 UTC

  Added files:                 
    /php-src/ext/standard/tests/array   array_map_variation2.phpt 
                                        array_map_variation1.phpt 
  Log:
  new tests for array_map usage variations - string keys and references
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_map_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_map_variation2.phpt
+++ php-src/ext/standard/tests/array/array_map_variation2.phpt
--TEST--
Test array_map() function : usage variations - references
--FILE--
<?php

/* Prototype  : array array_map(mixed callback, array input1 [, array input2 
,...])
 * Description: Applies the callback to the elements in given arrays.
 * Source code: ext/standard/array.c
*/

echo "*** Testing array_map() : references ***\n";
$arr = array("k1" => "v1","k2"=>"v2");
$arr[]=&$arr["k1"];
$arr[]=&$arr;
function cb1 ($a) {var_dump ($a);return array ($a);};
function cb2 (&$a) {var_dump ($a);return array (&$a);};
var_dump( array_map("cb1", $arr));
var_dump( array_map("cb2", $arr,$arr));
var_dump( array_map(null,  $arr));
var_dump( array_map(null, $arr, $arr));


echo "Done";
?>
--EXPECT--
*** Testing array_map() : references ***
string(2) "v1"
string(2) "v2"
string(2) "v1"
array(4) {
  ["k1"]=>
  &string(2) "v1"
  ["k2"]=>
  string(2) "v2"
  [0]=>
  &string(2) "v1"
  [1]=>
  &array(4) {
    ["k1"]=>
    &string(2) "v1"
    ["k2"]=>
    string(2) "v2"
    [0]=>
    &string(2) "v1"
    [1]=>
    &array(4) {
      ["k1"]=>
      &string(2) "v1"
      ["k2"]=>
      string(2) "v2"
      [0]=>
      &string(2) "v1"
      [1]=>
      *RECURSION*
    }
  }
}
array(4) {
  ["k1"]=>
  array(1) {
    [0]=>
    string(2) "v1"
  }
  ["k2"]=>
  array(1) {
    [0]=>
    string(2) "v2"
  }
  [0]=>
  array(1) {
    [0]=>
    string(2) "v1"
  }
  [1]=>
  array(1) {
    [0]=>
    array(4) {
      ["k1"]=>
      &string(2) "v1"
      ["k2"]=>
      string(2) "v2"
      [0]=>
      &string(2) "v1"
      [1]=>
      &array(4) {
        ["k1"]=>
        &string(2) "v1"
        ["k2"]=>
        string(2) "v2"
        [0]=>
        &string(2) "v1"
        [1]=>
        &array(4) {
          ["k1"]=>
          &string(2) "v1"
          ["k2"]=>
          string(2) "v2"
          [0]=>
          &string(2) "v1"
          [1]=>
          *RECURSION*
        }
      }
    }
  }
}
string(2) "v1"
string(2) "v2"
string(2) "v1"
array(4) {
  ["k1"]=>
  &string(2) "v1"
  ["k2"]=>
  string(2) "v2"
  [0]=>
  &string(2) "v1"
  [1]=>
  &array(4) {
    ["k1"]=>
    &string(2) "v1"
    ["k2"]=>
    string(2) "v2"
    [0]=>
    &string(2) "v1"
    [1]=>
    &array(4) {
      ["k1"]=>
      &string(2) "v1"
      ["k2"]=>
      string(2) "v2"
      [0]=>
      &string(2) "v1"
      [1]=>
      *RECURSION*
    }
  }
}
array(4) {
  [0]=>
  array(1) {
    [0]=>
    &string(2) "v1"
  }
  [1]=>
  array(1) {
    [0]=>
    string(2) "v2"
  }
  [2]=>
  array(1) {
    [0]=>
    &string(2) "v1"
  }
  [3]=>
  array(1) {
    [0]=>
    &array(4) {
      ["k1"]=>
      &string(2) "v1"
      ["k2"]=>
      string(2) "v2"
      [0]=>
      &string(2) "v1"
      [1]=>
      &array(4) {
        ["k1"]=>
        &string(2) "v1"
        ["k2"]=>
        string(2) "v2"
        [0]=>
        &string(2) "v1"
        [1]=>
        *RECURSION*
      }
    }
  }
}
array(4) {
  ["k1"]=>
  &string(2) "v1"
  ["k2"]=>
  string(2) "v2"
  [0]=>
  &string(2) "v1"
  [1]=>
  &array(4) {
    ["k1"]=>
    &string(2) "v1"
    ["k2"]=>
    string(2) "v2"
    [0]=>
    &string(2) "v1"
    [1]=>
    &array(4) {
      ["k1"]=>
      &string(2) "v1"
      ["k2"]=>
      string(2) "v2"
      [0]=>
      &string(2) "v1"
      [1]=>
      *RECURSION*
    }
  }
}
array(4) {
  [0]=>
  array(2) {
    [0]=>
    &string(2) "v1"
    [1]=>
    &string(2) "v1"
  }
  [1]=>
  array(2) {
    [0]=>
    string(2) "v2"
    [1]=>
    string(2) "v2"
  }
  [2]=>
  array(2) {
    [0]=>
    &string(2) "v1"
    [1]=>
    &string(2) "v1"
  }
  [3]=>
  array(2) {
    [0]=>
    &array(4) {
      ["k1"]=>
      &string(2) "v1"
      ["k2"]=>
      string(2) "v2"
      [0]=>
      &string(2) "v1"
      [1]=>
      &array(4) {
        ["k1"]=>
        &string(2) "v1"
        ["k2"]=>
        string(2) "v2"
        [0]=>
        &string(2) "v1"
        [1]=>
        *RECURSION*
      }
    }
    [1]=>
    &array(4) {
      ["k1"]=>
      &string(2) "v1"
      ["k2"]=>
      string(2) "v2"
      [0]=>
      &string(2) "v1"
      [1]=>
      &array(4) {
        ["k1"]=>
        &string(2) "v1"
        ["k2"]=>
        string(2) "v2"
        [0]=>
        &string(2) "v1"
        [1]=>
        *RECURSION*
      }
    }
  }
}
Done
--UEXPECT--
*** Testing array_map() : references ***
unicode(2) "v1"
unicode(2) "v2"
unicode(2) "v1"
array(4) {
  [u"k1"]=>
  &unicode(2) "v1"
  [u"k2"]=>
  unicode(2) "v2"
  [0]=>
  &unicode(2) "v1"
  [1]=>
  &array(4) {
    [u"k1"]=>
    &unicode(2) "v1"
    [u"k2"]=>
    unicode(2) "v2"
    [0]=>
    &unicode(2) "v1"
    [1]=>
    &array(4) {
      [u"k1"]=>
      &unicode(2) "v1"
      [u"k2"]=>
      unicode(2) "v2"
      [0]=>
      &unicode(2) "v1"
      [1]=>
      *RECURSION*
    }
  }
}
array(4) {
  [u"k1"]=>
  array(1) {
    [0]=>
    unicode(2) "v1"
  }
  [u"k2"]=>
  array(1) {
    [0]=>
    unicode(2) "v2"
  }
  [0]=>
  array(1) {
    [0]=>
    unicode(2) "v1"
  }
  [1]=>
  array(1) {
    [0]=>
    array(4) {
      [u"k1"]=>
      &unicode(2) "v1"
      [u"k2"]=>
      unicode(2) "v2"
      [0]=>
      &unicode(2) "v1"
      [1]=>
      &array(4) {
        [u"k1"]=>
        &unicode(2) "v1"
        [u"k2"]=>
        unicode(2) "v2"
        [0]=>
        &unicode(2) "v1"
        [1]=>
        &array(4) {
          [u"k1"]=>
          &unicode(2) "v1"
          [u"k2"]=>
          unicode(2) "v2"
          [0]=>
          &unicode(2) "v1"
          [1]=>
          *RECURSION*
        }
      }
    }
  }
}
unicode(2) "v1"
unicode(2) "v2"
unicode(2) "v1"
array(4) {
  [u"k1"]=>
  &unicode(2) "v1"
  [u"k2"]=>
  unicode(2) "v2"
  [0]=>
  &unicode(2) "v1"
  [1]=>
  &array(4) {
    [u"k1"]=>
    &unicode(2) "v1"
    [u"k2"]=>
    unicode(2) "v2"
    [0]=>
    &unicode(2) "v1"
    [1]=>
    &array(4) {
      [u"k1"]=>
      &unicode(2) "v1"
      [u"k2"]=>
      unicode(2) "v2"
      [0]=>
      &unicode(2) "v1"
      [1]=>
      *RECURSION*
    }
  }
}
array(4) {
  [0]=>
  array(1) {
    [0]=>
    &unicode(2) "v1"
  }
  [1]=>
  array(1) {
    [0]=>
    unicode(2) "v2"
  }
  [2]=>
  array(1) {
    [0]=>
    &unicode(2) "v1"
  }
  [3]=>
  array(1) {
    [0]=>
    &array(4) {
      [u"k1"]=>
      &unicode(2) "v1"
      [u"k2"]=>
      unicode(2) "v2"
      [0]=>
      &unicode(2) "v1"
      [1]=>
      &array(4) {
        [u"k1"]=>
        &unicode(2) "v1"
        [u"k2"]=>
        unicode(2) "v2"
        [0]=>
        &unicode(2) "v1"
        [1]=>
        *RECURSION*
      }
    }
  }
}
array(4) {
  [u"k1"]=>
  &unicode(2) "v1"
  [u"k2"]=>
  unicode(2) "v2"
  [0]=>
  &unicode(2) "v1"
  [1]=>
  &array(4) {
    [u"k1"]=>
    &unicode(2) "v1"
    [u"k2"]=>
    unicode(2) "v2"
    [0]=>
    &unicode(2) "v1"
    [1]=>
    &array(4) {
      [u"k1"]=>
      &unicode(2) "v1"
      [u"k2"]=>
      unicode(2) "v2"
      [0]=>
      &unicode(2) "v1"
      [1]=>
      *RECURSION*
    }
  }
}
array(4) {
  [0]=>
  array(2) {
    [0]=>
    &unicode(2) "v1"
    [1]=>
    &unicode(2) "v1"
  }
  [1]=>
  array(2) {
    [0]=>
    unicode(2) "v2"
    [1]=>
    unicode(2) "v2"
  }
  [2]=>
  array(2) {
    [0]=>
    &unicode(2) "v1"
    [1]=>
    &unicode(2) "v1"
  }
  [3]=>
  array(2) {
    [0]=>
    &array(4) {
      [u"k1"]=>
      &unicode(2) "v1"
      [u"k2"]=>
      unicode(2) "v2"
      [0]=>
      &unicode(2) "v1"
      [1]=>
      &array(4) {
        [u"k1"]=>
        &unicode(2) "v1"
        [u"k2"]=>
        unicode(2) "v2"
        [0]=>
        &unicode(2) "v1"
        [1]=>
        *RECURSION*
      }
    }
    [1]=>
    &array(4) {
      [u"k1"]=>
      &unicode(2) "v1"
      [u"k2"]=>
      unicode(2) "v2"
      [0]=>
      &unicode(2) "v1"
      [1]=>
      &array(4) {
        [u"k1"]=>
        &unicode(2) "v1"
        [u"k2"]=>
        unicode(2) "v2"
        [0]=>
        &unicode(2) "v1"
        [1]=>
        *RECURSION*
      }
    }
  }
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_map_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_map_variation1.phpt
+++ php-src/ext/standard/tests/array/array_map_variation1.phpt
--TEST--
Test array_map() function : usage variations - string keys
--FILE--
<?php

/* Prototype  : array array_map(mixed callback, array input1 [, array input2 
,...])
 * Description: Applies the callback to the elements in given arrays.
 * Source code: ext/standard/array.c
*/



echo "*** Testing array_map() : string keys ***\n";

$arr = array("stringkey" => "value");
function cb1 ($a) {return array ($a);};
function cb2 ($a,$b) {return array ($a,$b);};
var_dump( array_map("cb1", $arr));
var_dump( array_map("cb2", $arr,$arr));
var_dump( array_map(null,  $arr));
var_dump( array_map(null, $arr, $arr));
echo "Done";
?>
--EXPECT--
*** Testing array_map() : string keys ***
array(1) {
  ["stringkey"]=>
  array(1) {
    [0]=>
    string(5) "value"
  }
}
array(1) {
  [0]=>
  array(2) {
    [0]=>
    string(5) "value"
    [1]=>
    string(5) "value"
  }
}
array(1) {
  ["stringkey"]=>
  string(5) "value"
}
array(1) {
  [0]=>
  array(2) {
    [0]=>
    string(5) "value"
    [1]=>
    string(5) "value"
  }
}
Done
--UEXPECT--
*** Testing array_map() : string keys ***
array(1) {
  [u"stringkey"]=>
  array(1) {
    [0]=>
    unicode(5) "value"
  }
}
array(1) {
  [0]=>
  array(2) {
    [0]=>
    unicode(5) "value"
    [1]=>
    unicode(5) "value"
  }
}
array(1) {
  [u"stringkey"]=>
  unicode(5) "value"
}
array(1) {
  [0]=>
  array(2) {
    [0]=>
    unicode(5) "value"
    [1]=>
    unicode(5) "value"
  }
}
Done
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to