blob: d578f9c8d2764b350f127d398103e88680d86f96 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
--TEST--
Bug #69957 (Different ways of handling div/mod by zero)
--FILE--
<?php
try {
$divisor = 0;
$result = 1 / $divisor;
var_dump($result);
} catch (DivisionByZeroError $t){
echo "Variable div\n";
printf("Type: %s\n", get_class($t));
printf("Message: %s\n", $t->getMessage());
}
try {
$divisor = 0;
$result = 1 % $divisor;
var_dump($result);
} catch (DivisionByZeroError $t){
echo "\nVariable mod\n";
printf("Type: %s\n", get_class($t));
printf("Message: %s\n", $t->getMessage());
}
try {
$result = 1 / 0;
var_dump($result);
} catch (DivisionByZeroError $t){
echo "\nLiteral div\n";
printf("Type: %s\n", get_class($t));
printf("Message: %s\n", $t->getMessage());
}
try {
$result = 1 % 0;
var_dump($result);
} catch (DivisionByZeroError $t){
echo "\nLiteral mod\n";
printf("Type: %s\n", get_class($t));
printf("Message: %s\n", $t->getMessage());
}
try {
$result = 1 / 0.0;
var_dump($result);
} catch (DivisionByZeroError $t){
echo "\nDouble div\n";
printf("Type: %s\n", get_class($t));
printf("Message: %s\n", $t->getMessage());
}
try {
$result = 1 % 0.0;
var_dump($result);
} catch (DivisionByZeroError $t){
echo "\nDouble mod\n";
printf("Type: %s\n", get_class($t));
printf("Message: %s\n", $t->getMessage());
}
?>
--EXPECTF--
Warning: Division by zero in %sbug69957.php on line %d
float(INF)
Variable mod
Type: DivisionByZeroError
Message: Modulo by zero
Warning: Division by zero in %sbug69957.php on line %d
float(INF)
Literal mod
Type: DivisionByZeroError
Message: Modulo by zero
Warning: Division by zero in %sbug69957.php on line %d
float(INF)
Double mod
Type: DivisionByZeroError
Message: Modulo by zero
|