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

1.1       misho       1: --TEST--
                      2: Test array_sum() function : usage variations - array with different float values
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : mixed array_sum(array $input)
                      6:  * Description: Returns the sum of the array entries 
                      7:  * Source code: ext/standard/array.c
                      8: */
                      9: 
                     10: /*
                     11:  * sum of array containing different float values
                     12: */
                     13: 
                     14: echo "*** Testing array_sum() : array with different float values ***\n";
                     15: 
                     16: // Simple float array
                     17: $float_input = array( 1.1, 2.3, 0.0, 0.5, -2.3, -0.8, .5);
                     18: echo "-- simple float array --\n";
                     19: var_dump( array_sum($float_input) );
                     20: 
                     21: // float array with scientific notations
                     22: $float_input = array( 1.2e2, 23.4e3, -4.1e2, 0.2e2, 2.1e-2, .5e3);
                     23: echo "-- float array with scientific notations e and E --\n";
                     24: var_dump( array_sum($float_input) );
                     25: $float_input = array( 1.2E2, 23.4E3, -4.1E2, 0.2E2, 2.1E-2, .5E3);
                     26: var_dump( array_sum($float_input) );
                     27: 
                     28: // Mixed float array
                     29: $float_input = array( 
                     30:   1.2,
                     31:   0.5
                     32:   -5.8,
                     33:   6.334,
                     34:   -0.65,
                     35:   1.2e3,
                     36:   -2.3e2,
                     37:   5.56E3,
                     38:   -3.82E-2
                     39: );
                     40: echo "-- Mixed float array --\n";
                     41: var_dump( array_sum($float_input) );
                     42:                      
                     43: echo "Done"
                     44: ?>
                     45: --EXPECTF--
                     46: *** Testing array_sum() : array with different float values ***
                     47: -- simple float array --
                     48: float(1.3)
                     49: -- float array with scientific notations e and E --
                     50: float(23630.021)
                     51: float(23630.021)
                     52: -- Mixed float array --
                     53: float(6531.5458)
                     54: Done

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