Skip to content

Commit 2289e0b

Browse files
committed
Migrate remaining compat tests to simdjson_decode
1 parent 257b7a2 commit 2289e0b

File tree

7 files changed

+25
-32
lines changed

7 files changed

+25
-32
lines changed

.github/workflows/integration.yml

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ jobs:
104104
- "7.3"
105105
- "7.4"
106106
- "8.0"
107+
- "8.1"
107108
os: [ubuntu-latest]
108109
experimental: [false]
109110
runs-on: ${{ matrix.os }}

tests/compat/bug41067.phpt

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@
22
Bug #41067 compat test (json_encode() problem with UTF-16 input)
33
--FILE--
44
<?php
5-
$single_barline = "\360\235\204\200";
6-
$array = array($single_barline);
7-
print bin2hex($single_barline) . "\n";
8-
// print $single_barline . "\n\n";
9-
$json = json_encode($array);
10-
print $json . "\n\n";
5+
$json = '["\ud834\udd00"]';
116
$json_decoded = simdjson_decode($json, true);
127
// print $json_decoded[0] . "\n";
138
print bin2hex($json_decoded[0]) . "\n";
149
print "END\n";
1510
?>
1611
--EXPECT--
17-
f09d8480
18-
["\ud834\udd00"]
19-
2012
f09d8480
2113
END

tests/compat/bug64874_part2.phpt

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Case-sensitivity part of bug #64874 compat ("json_decode handles whitespace and
44
<?php
55
function decode($json) {
66
try {
7-
var_dump(json_decode($json));
7+
var_dump(simdjson_decode($json));
88
} catch (RuntimeException $e) {
99
printf("Caught %s: %s\n", get_class($e), $e->getMessage());
1010
}
@@ -33,27 +33,27 @@ echo "Done\n";
3333
?>
3434
--EXPECT--
3535
bool(true)
36-
NULL
36+
Caught RuntimeException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
3737
array(1) {
3838
[0]=>
3939
bool(true)
4040
}
41-
NULL
41+
Caught RuntimeException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
4242

4343
bool(false)
44-
NULL
44+
Caught RuntimeException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
4545
array(1) {
4646
[0]=>
4747
bool(false)
4848
}
49-
NULL
49+
Caught RuntimeException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
5050

5151
NULL
52-
NULL
52+
Caught RuntimeException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
5353
array(1) {
5454
[0]=>
5555
NULL
5656
}
57-
NULL
57+
Caught RuntimeException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
5858

5959
Done

tests/compat/pass001.1.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ $test = "
7676

7777
echo 'Testing:' . $test . "\n";
7878
echo "DECODE: AS OBJECT\n";
79-
$obj = json_decode($test);
79+
$obj = simdjson_decode($test);
8080
var_dump($obj);
8181
echo "DECODE: AS ARRAY\n";
82-
$arr = json_decode($test, true);
82+
$arr = simdjson_decode($test, true);
8383
var_dump($arr);
8484

8585
echo "ENCODE: FROM OBJECT\n";
@@ -90,10 +90,10 @@ $arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR);
9090
echo $arr_enc . "\n";
9191

9292
echo "DECODE AGAIN: AS OBJECT\n";
93-
$obj = json_decode($obj_enc);
93+
$obj = simdjson_decode($obj_enc);
9494
var_dump($obj);
9595
echo "DECODE AGAIN: AS ARRAY\n";
96-
$arr = json_decode($arr_enc, true);
96+
$arr = simdjson_decode($arr_enc, true);
9797
var_dump($arr);
9898

9999
?>

tests/compat/pass001.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ $test = "
6666

6767
echo 'Testing:' . $test . "\n";
6868
echo "DECODE: AS OBJECT\n";
69-
$obj = json_decode($test);
69+
$obj = simdjson_decode($test);
7070
var_dump($obj);
7171
echo "DECODE: AS ARRAY\n";
72-
$arr = json_decode($test, true);
72+
$arr = simdjson_decode($test, true);
7373
var_dump($arr);
7474

7575
echo "ENCODE: FROM OBJECT\n";
@@ -80,10 +80,10 @@ $arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR);
8080
echo $arr_enc . "\n";
8181

8282
echo "DECODE AGAIN: AS OBJECT\n";
83-
$obj = json_decode($obj_enc);
83+
$obj = simdjson_decode($obj_enc);
8484
var_dump($obj);
8585
echo "DECODE AGAIN: AS ARRAY\n";
86-
$arr = json_decode($arr_enc, true);
86+
$arr = simdjson_decode($arr_enc, true);
8787
var_dump($arr);
8888

8989
?>

tests/compat/pass002.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ JSON (http://www.crockford.com/JSON/JSON_checker/test/pass2.json)
66
$test = '[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]';
77
echo 'Testing: ' . $test . "\n";
88
echo "DECODE: AS OBJECT\n";
9-
$obj = json_decode($test);
9+
$obj = simdjson_decode($test);
1010
var_dump($obj);
1111
echo "DECODE: AS ARRAY\n";
12-
$arr = json_decode($test, true);
12+
$arr = simdjson_decode($test, true);
1313
var_dump($arr);
1414

1515
echo "ENCODE: FROM OBJECT\n";
@@ -20,10 +20,10 @@ $arr_enc = json_encode($arr);
2020
echo $arr_enc . "\n";
2121

2222
echo "DECODE AGAIN: AS OBJECT\n";
23-
$obj = json_decode($obj_enc);
23+
$obj = simdjson_decode($obj_enc);
2424
var_dump($obj);
2525
echo "DECODE AGAIN: AS ARRAY\n";
26-
$arr = json_decode($arr_enc, true);
26+
$arr = simdjson_decode($arr_enc, true);
2727
var_dump($arr);
2828

2929
?>

tests/compat/pass003.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ $test = '
1414

1515
echo 'Testing:' . $test . "\n";
1616
echo "DECODE: AS OBJECT\n";
17-
$obj = json_decode($test);
17+
$obj = simdjson_decode($test);
1818
var_dump($obj);
1919
echo "DECODE: AS ARRAY\n";
20-
$arr = json_decode($test, true);
20+
$arr = simdjson_decode($test, true);
2121
var_dump($arr);
2222

2323
echo "ENCODE: FROM OBJECT\n";
@@ -28,10 +28,10 @@ $arr_enc = json_encode($arr);
2828
echo $arr_enc . "\n";
2929

3030
echo "DECODE AGAIN: AS OBJECT\n";
31-
$obj = json_decode($obj_enc);
31+
$obj = simdjson_decode($obj_enc);
3232
var_dump($obj);
3333
echo "DECODE AGAIN: AS ARRAY\n";
34-
$arr = json_decode($arr_enc, true);
34+
$arr = simdjson_decode($arr_enc, true);
3535
var_dump($arr);
3636

3737
?>

0 commit comments

Comments
 (0)