Annotation of embedaddon/php/ext/standard/tests/math/floor_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test floor() function : usage variations - different data types as $value arg
3: --INI--
4: precision=14
5: --FILE--
6: <?php
7: /* Prototype : float floor ( float $value )
8: * Description: Round fractions down.
9: * Source code: ext/standard/math.c
10: */
11:
12: echo "*** Testing floor() : usage variations ***\n";
13: //get an unset variable
14: $unset_var = 10;
15: unset ($unset_var);
16:
17: // get a class
18: class classA
19: {
20: }
21:
22: // heredoc string
23: $heredoc = <<<EOT
24: abc
25: xyz
26: EOT;
27:
28: // get a resource variable
29: $fp = fopen(__FILE__, "r");
30:
31: // unexpected values to be passed to $value argument
32: $inputs = array(
33: // null data
34: /* 1*/ NULL,
35: null,
36:
37: // boolean data
38: /* 3*/ true,
39: false,
40: TRUE,
41: FALSE,
42:
43: // empty data
44: /* 7*/ "",
45: '',
46: array(),
47:
48: // string data
49: /*10*/ "abcxyz",
50: 'abcxyz}',
51: $heredoc,
52:
53: // object data
54: /*13*/ new classA(),
55:
56: // undefined data
57: /*14*/ @$undefined_var,
58:
59: // unset data
60: /*15*/ @$unset_var,
61:
62: // resource variable
63: /*16*/ $fp
64: );
65:
66: // loop through each element of $inputs to check the behaviour of floor()
67: $iterator = 1;
68: foreach($inputs as $input) {
69: echo "\n-- Iteration $iterator --\n";
70: var_dump(floor($input));
71: $iterator++;
72: };
73: fclose($fp);
74: ?>
75: ===Done===
76: --EXPECTF--
77: *** Testing floor() : usage variations ***
78:
79: -- Iteration 1 --
80: float(0)
81:
82: -- Iteration 2 --
83: float(0)
84:
85: -- Iteration 3 --
86: float(1)
87:
88: -- Iteration 4 --
89: float(0)
90:
91: -- Iteration 5 --
92: float(1)
93:
94: -- Iteration 6 --
95: float(0)
96:
97: -- Iteration 7 --
98: float(0)
99:
100: -- Iteration 8 --
101: float(0)
102:
103: -- Iteration 9 --
104: bool(false)
105:
106: -- Iteration 10 --
107: float(0)
108:
109: -- Iteration 11 --
110: float(0)
111:
112: -- Iteration 12 --
113: float(0)
114:
115: -- Iteration 13 --
116:
117: Notice: Object of class classA could not be converted to int in %s on line %d
118: float(1)
119:
120: -- Iteration 14 --
121: float(0)
122:
123: -- Iteration 15 --
124: float(0)
125:
126: -- Iteration 16 --
127: float(%f)
128: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>