summaryrefslogtreecommitdiff
path: root/ext/date/tests/microtime_error.phpt
blob: ce13875e67b1a9c82f45b293f2bf05ca44f6d22e (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
--TEST--
Test wrong number of arguments for microtime()
--FILE--
<?php
/*
 * 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(): Argument #1 ($as_float) must be of type bool, array given

--> bad arg: object(stdClass)#%d (0) {
}
microtime(): Argument #1 ($as_float) must be of type bool, stdClass given

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