Revision 19792,
826 bytes
checked in by Seasoft, 13 years ago
(diff) |
#744(PHP4 互換用途ソースを将来的に切り捨てやすい仕組みづくり)
|
Line | |
---|
1 | --TEST-- |
---|
2 | Function -- array_product |
---|
3 | --SKIPIF-- |
---|
4 | <?php if (function_exists('array_product')) { echo 'skip'; } ?> |
---|
5 | --FILE-- |
---|
6 | <?php |
---|
7 | require_once 'PHP/Compat.php'; |
---|
8 | PHP_Compat::loadFunction('array_product'); |
---|
9 | |
---|
10 | function ehandler($no, $str) |
---|
11 | { |
---|
12 | echo '(Warning) '; |
---|
13 | } |
---|
14 | set_error_handler('ehandler'); |
---|
15 | |
---|
16 | $tests = array( |
---|
17 | 'foo', |
---|
18 | array(), |
---|
19 | array(0), |
---|
20 | array(3), |
---|
21 | array(3, 3), |
---|
22 | array(0.5, 2, 3) |
---|
23 | ); |
---|
24 | |
---|
25 | foreach ($tests as $v) { |
---|
26 | echo "testing: (", (is_array($v) ? implode(' * ', $v) : $v), ")\n result: "; |
---|
27 | var_dump(array_product($v)); |
---|
28 | echo "\n\n"; |
---|
29 | } |
---|
30 | |
---|
31 | restore_error_handler(); |
---|
32 | ?> |
---|
33 | --EXPECT-- |
---|
34 | testing: (foo) |
---|
35 | result: (Warning) NULL |
---|
36 | |
---|
37 | |
---|
38 | testing: () |
---|
39 | result: int(0) |
---|
40 | |
---|
41 | |
---|
42 | testing: (0) |
---|
43 | result: int(0) |
---|
44 | |
---|
45 | |
---|
46 | testing: (3) |
---|
47 | result: int(3) |
---|
48 | |
---|
49 | |
---|
50 | testing: (3 * 3) |
---|
51 | result: int(9) |
---|
52 | |
---|
53 | |
---|
54 | testing: (0.5 * 2 * 3) |
---|
55 | result: float(3) |
---|
Note: See
TracBrowser
for help on using the repository browser.