1--TEST--
2Test fseek() function : usage variations  - different types for whence
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
7--FILE--
8<?php
9/* Prototype  : proto int fseek(resource fp, int offset [, int whence])
10 * Description: Seek on a file pointer
11 * Source code: ext/standard/file.c
12 * Alias to functions: gzseek
13 */
14
15echo "*** Testing fseek() : usage variations ***\n";
16error_reporting(E_ALL & ~E_NOTICE);
17$fp = fopen(__FILE__, 'r');
18$offset = 3;
19
20//get an unset variable
21$unset_var = 10;
22unset ($unset_var);
23
24//array of values to iterate over
25$values = array(
26
27      // outside of whence range
28      -100,
29      100,
30
31      // float data
32      10.5,
33      -10.5,
34      10.1234567e10,
35      10.7654321E-10,
36      .5,
37
38      // null data
39      NULL,
40      null,
41
42      // boolean data
43      true,
44      false,
45      TRUE,
46      FALSE,
47
48      // empty data
49      "",
50      '',
51
52      // string data
53      "string",
54      'string',
55
56      // undefined data
57      $undefined_var,
58
59      // unset data
60      $unset_var,
61);
62
63// loop through each element of the array for whence
64
65foreach($values as $value) {
66      echo "\nArg value $value \n";
67      var_dump( fseek($fp, $offset, $value) );
68      var_dump( ftell($fp));
69};
70
71fclose($fp);
72echo "Done";
73?>
74--EXPECTF--
75*** Testing fseek() : usage variations ***
76
77Arg value -100
78int(-1)
79int(0)
80
81Arg value 100
82int(-1)
83int(0)
84
85Arg value 10.5
86int(-1)
87int(0)
88
89Arg value -10.5
90int(-1)
91int(0)
92
93Arg value 101234567000
94int(-1)
95int(0)
96
97Arg value 1.07654321E-9
98int(0)
99int(3)
100
101Arg value 0.5
102int(0)
103int(3)
104
105Arg value
106int(0)
107int(3)
108
109Arg value
110int(0)
111int(3)
112
113Arg value 1
114int(0)
115int(6)
116
117Arg value
118int(0)
119int(3)
120
121Arg value 1
122int(0)
123int(6)
124
125Arg value
126int(0)
127int(3)
128
129Arg value
130
131Warning: fseek() expects parameter 3 to be int, string given in %s on line %d
132bool(false)
133int(3)
134
135Arg value
136
137Warning: fseek() expects parameter 3 to be int, string given in %s on line %d
138bool(false)
139int(3)
140
141Arg value string
142
143Warning: fseek() expects parameter 3 to be int, string given in %s on line %d
144bool(false)
145int(3)
146
147Arg value string
148
149Warning: fseek() expects parameter 3 to be int, string given in %s on line %d
150bool(false)
151int(3)
152
153Arg value
154int(0)
155int(3)
156
157Arg value
158int(0)
159int(3)
160Done
161