summaryrefslogtreecommitdiff
path: root/ext/date/tests/microtime_error.phpt
blob: 151bead6def2be81f9a27d44c5cdd41c6442966a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--TEST--
Test wrong number of arguments for microtime()
--FILE--
<?php
/*
 * proto mixed microtime([bool get_as_float])
 * Function is implemented in ext/standard/microtime.c
*/

echo "\n-- Bad Arg types --\n";

$bad_args = array(null,
				  1.5,
				  "hello",
				  array('k'=>'v', array(0)),
				  new stdClass,
				  1);
foreach ($bad_args as $bad_arg) {
	echo "\n--> bad arg: ";
	var_dump($bad_arg);
	try {
		var_dump(microtime($bad_arg));
	} catch (TypeError $e) {
		echo $e->getMessage(), "\n";
	}
}

?>
--EXPECTF--
-- Bad Arg types --

--> bad arg: NULL
string(%d) "%s %s"

--> bad arg: float(1.5)
float(%s)

--> bad arg: string(5) "hello"
float(%s)

--> bad arg: array(2) {
  ["k"]=>
  string(1) "v"
  [0]=>
  array(1) {
    [0]=>
    int(0)
  }
}
microtime() expects parameter 1 to be bool, array given

--> bad arg: object(stdClass)#%d (0) {
}
microtime() expects parameter 1 to be bool, object given

--> bad arg: int(1)
float(%s)