xref: /PHP-7.0/ext/json/tests/bug41403.phpt (revision e5abc537)
1--TEST--
2Bug #41403 (json_decode cannot decode floats if localeconv decimal_point is not '.')
3--SKIPIF--
4<?php
5if (!extension_loaded('json')) die('skip');
6if (setlocale(LC_NUMERIC, "de_DE") === false) {
7	die("skip no de_DE locale");
8}
9?>
10--INI--
11precision=14
12--FILE--
13<?php
14
15setlocale(LC_NUMERIC, 'de_DE');
16var_dump(json_decode('[2.1]'));
17var_dump(json_decode('[0.15]'));
18var_dump(json_decode('[123.13452345]'));
19var_dump(json_decode('[123,13452345]'));
20
21echo "Done\n";
22?>
23--EXPECTF--
24array(1) {
25  [0]=>
26  float(2,1)
27}
28array(1) {
29  [0]=>
30  float(0,15)
31}
32array(1) {
33  [0]=>
34  float(123,13452345)
35}
36array(2) {
37  [0]=>
38  int(123)
39  [1]=>
40  int(13452345)
41}
42Done
43