Annotation of embedaddon/php/ext/standard/tests/strings/print_variation1.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test print() function : usage variations
3: --FILE--
4: <?php
5:
6: /* Prototype : int print ( string $arg )
7: * Description: Output a string
8: * Source code: n/a, print is a language construct not an extension function
9: * Test based on php.net manual example.
10: */
11:
12: echo "*** Testing print() function: with unexpected inputs for 'arg' argument ***\n";
13:
14: //get an unset variable
15: $unset_var = 'string_val';
16: unset($unset_var);
17:
18: //defining a class
19: class sample {
20: public function __toString() {
21: return "sample object";
22: }
23: }
24:
25: //getting the resource
26: $file_handle = fopen(__FILE__, "r");
27:
28: // array with different values for $input
29: $inputs = array (
30:
31: // integer values
32: /*1*/ 0,
33: 1,
34: -2,
35: 2147483647,
36: -2147483648,
37:
38: // float values
39: /*6*/ 10.5,
40: -20.5,
41: 10.1234567e10,
42:
43: // array values
44: /*9*/ array(),
45: array(0),
46: array(1, 2),
47:
48: // boolean values
49: /*12*/ true,
50: false,
51: TRUE,
52: FALSE,
53:
54: // null vlaues
55: /*16*/ NULL,
56: null,
57:
58: // objects
59: /*18*/ new sample(),
60:
61: // resource
62: /*19*/ $file_handle,
63:
64: // undefined variable
65: /*20*/ @$undefined_var,
66:
67: // unset variable
68: /*21*/ @$unset_var
69: );
70:
71: // loop through with each element of the $inputs array to test print() function
72: $count = 1;
73: foreach($inputs as $input) {
74: echo "-- Iteration $count --\n";
75: $res = print($input);
76: echo "\n";
77: var_dump($res);
78: $count ++;
79: }
80:
81: fclose($file_handle); //closing the file handle
82:
83: ?>
84: ===DONE===
85: --EXPECTF--
86: *** Testing print() function: with unexpected inputs for 'arg' argument ***
87: -- Iteration 1 --
88: 0
89: int(1)
90: -- Iteration 2 --
91: 1
92: int(1)
93: -- Iteration 3 --
94: -2
95: int(1)
96: -- Iteration 4 --
97: 2147483647
98: int(1)
99: -- Iteration 5 --
100: -2147483648
101: int(1)
102: -- Iteration 6 --
103: 10.5
104: int(1)
105: -- Iteration 7 --
106: -20.5
107: int(1)
108: -- Iteration 8 --
109: 101234567000
110: int(1)
111: -- Iteration 9 --
1.1.1.2 ! misho 112:
! 113: Notice: Array to string conversion in %sprint_variation1.php on line %d
1.1 misho 114: Array
115: int(1)
116: -- Iteration 10 --
1.1.1.2 ! misho 117:
! 118: Notice: Array to string conversion in %sprint_variation1.php on line %d
1.1 misho 119: Array
120: int(1)
121: -- Iteration 11 --
1.1.1.2 ! misho 122:
! 123: Notice: Array to string conversion in %sprint_variation1.php on line %d
1.1 misho 124: Array
125: int(1)
126: -- Iteration 12 --
127: 1
128: int(1)
129: -- Iteration 13 --
130:
131: int(1)
132: -- Iteration 14 --
133: 1
134: int(1)
135: -- Iteration 15 --
136:
137: int(1)
138: -- Iteration 16 --
139:
140: int(1)
141: -- Iteration 17 --
142:
143: int(1)
144: -- Iteration 18 --
145: sample object
146: int(1)
147: -- Iteration 19 --
148: Resource id #%d
149: int(1)
150: -- Iteration 20 --
151:
152: int(1)
153: -- Iteration 21 --
154:
155: int(1)
156: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>