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

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

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