Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_uassoc_variation5.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test array_intersect_uassoc() function : usage variation - Intersection of integers with floats and strings.
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_intersect_uassoc(array arr1, array arr2 [, array ...], callback key_compare_func)
                      6:  * Description: Computes the intersection of arrays with additional index check, compares indexes by a callback function
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: echo "*** Testing array_intersect_uassoc() : usage variation ***\n";
                     11: 
                     12: //Initialize variables
                     13: $arr_default_int = array(1, 2 );
                     14: $arr_float = array(0 => 1.00, 1.00 => 2.00, 2.00 => 3.00);
                     15: $arr_string = array('1', '2', '3');
                     16: $arr_string_float = array('1.00', '2.00');
                     17: 
                     18: function key_compare_func($a, $b)
                     19: {
                     20:     if ($a === $b) {
                     21:         return 0;
                     22:     }
                     23:     return ($a > $b)? 1:-1;
                     24: }
                     25: 
                     26: echo "\n-- Result of integers and floating point intersection --\n";
                     27: var_dump( array_intersect_uassoc($arr_default_int, $arr_float, "key_compare_func") );
                     28: 
                     29: echo "\n-- Result of integers and strings containing integers intersection --\n";
                     30: var_dump( array_intersect_uassoc($arr_default_int, $arr_string, "key_compare_func") );
                     31: 
                     32: echo "\n-- Result of integers and strings containing floating points intersection --\n";
                     33: var_dump( array_intersect_uassoc($arr_default_int, $arr_string_float, "key_compare_func") );
                     34: ?>
                     35: ===DONE===
                     36: --EXPECTF--
                     37: *** Testing array_intersect_uassoc() : usage variation ***
                     38: 
                     39: -- Result of integers and floating point intersection --
                     40: array(2) {
                     41:   [0]=>
                     42:   int(1)
                     43:   [1]=>
                     44:   int(2)
                     45: }
                     46: 
                     47: -- Result of integers and strings containing integers intersection --
                     48: array(2) {
                     49:   [0]=>
                     50:   int(1)
                     51:   [1]=>
                     52:   int(2)
                     53: }
                     54: 
                     55: -- Result of integers and strings containing floating points intersection --
                     56: array(0) {
                     57: }
                     58: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>