1--TEST--
2Test ctype_punct() function : usage variations - different data types as $c argument
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7/* Prototype  : bool ctype_punct(mixed $c)
8 * Description: Checks for any printable character which is not whitespace
9 * or an alphanumeric character
10 * Source code: ext/ctype/ctype.c
11 */
12
13/*
14 * Pass different data types as $c argument to ctype_punt() to test behaviour
15 */
16
17echo "*** Testing ctype_punct() : usage variations ***\n";
18
19$orig = setlocale(LC_CTYPE, "C");
20
21//get an unset variable
22$unset_var = 10;
23unset ($unset_var);
24
25// get a class
26class classA
27{
28  public function __toString() {
29    return ",<.>";
30  }
31}
32
33// heredoc string
34$heredoc = <<<EOT
35[{}]
36EOT;
37
38// get a resource variable
39$fp = fopen(__FILE__, "r");
40
41// unexpected values to be passed to $c argument
42$inputs = array(
43
44       // int data
45/*1*/  0,
46       1,
47       12345,
48       -2345,
49
50       // float data
51/*5*/  10.5,
52       -10.5,
53       12.3456789000e10,
54       12.3456789000E-10,
55       .5,
56
57       // null data
58/*10*/ NULL,
59       null,
60
61       // boolean data
62/*12*/ true,
63       false,
64       TRUE,
65       FALSE,
66
67       // empty data
68/*16*/ "",
69       '',
70       array(),
71
72       // string data
73/*19*/ ";:'@",
74       '#~/?',
75       $heredoc,
76
77       // object data
78/*22*/ new classA(),
79
80       // undefined data
81/*23*/ @$undefined_var,
82
83       // unset data
84/*24*/ @$unset_var,
85
86       // resource variable
87/*25*/ $fp
88);
89
90// loop through each element of $inputs to check the behavior of ctype_punct
91$iterator = 1;
92foreach($inputs as $input) {
93  echo "\n-- Iteration $iterator --\n";
94  var_dump( ctype_punct($input) );
95  $iterator++;
96};
97
98fclose($fp);
99
100setlocale(LC_CTYPE, $orig);
101?>
102===DONE===
103--EXPECTF--
104*** Testing ctype_punct() : usage variations ***
105
106-- Iteration 1 --
107bool(false)
108
109-- Iteration 2 --
110bool(false)
111
112-- Iteration 3 --
113bool(false)
114
115-- Iteration 4 --
116bool(false)
117
118-- Iteration 5 --
119bool(false)
120
121-- Iteration 6 --
122bool(false)
123
124-- Iteration 7 --
125bool(false)
126
127-- Iteration 8 --
128bool(false)
129
130-- Iteration 9 --
131bool(false)
132
133-- Iteration 10 --
134bool(false)
135
136-- Iteration 11 --
137bool(false)
138
139-- Iteration 12 --
140bool(false)
141
142-- Iteration 13 --
143bool(false)
144
145-- Iteration 14 --
146bool(false)
147
148-- Iteration 15 --
149bool(false)
150
151-- Iteration 16 --
152bool(false)
153
154-- Iteration 17 --
155bool(false)
156
157-- Iteration 18 --
158bool(false)
159
160-- Iteration 19 --
161bool(true)
162
163-- Iteration 20 --
164bool(true)
165
166-- Iteration 21 --
167bool(true)
168
169-- Iteration 22 --
170bool(false)
171
172-- Iteration 23 --
173bool(false)
174
175-- Iteration 24 --
176bool(false)
177
178-- Iteration 25 --
179bool(false)
180===DONE===
181