summaryrefslogtreecommitdiff
path: root/ext/json/tests/inf_nan_error.phpt
blob: a3ed5e7b882945e801f8ea54f5deda08802be330 (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
--TEST--
An error is thrown when INF or NaN are encoded
--FILE--
<?php

$inf = INF;

var_dump($inf);

var_dump(json_encode($inf));
var_dump(json_last_error());

var_dump(json_encode($inf, JSON_PARTIAL_OUTPUT_ON_ERROR));
var_dump(json_last_error());

$nan = NAN;

var_dump($nan);

var_dump(json_encode($nan));
var_dump(json_last_error());

var_dump(json_encode($nan, JSON_PARTIAL_OUTPUT_ON_ERROR));
var_dump(json_last_error());
?>
--EXPECTF--
float(INF)

Warning: json_encode(): double INF does not conform to the JSON spec in %s on line %d
bool(false)
int(7)

Warning: json_encode(): double INF does not conform to the JSON spec in %s on line %d
string(1) "0"
int(7)
float(NAN)

Warning: json_encode(): double NAN does not conform to the JSON spec in %s on line %d
bool(false)
int(7)

Warning: json_encode(): double NAN does not conform to the JSON spec in %s on line %d
string(1) "0"
int(7)