Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tests/HJSONParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class HJSONParserTest
public function assertEquals($a, $b)
{
if ($a !== $b) {
// for ($i=0; $i<strlen($a); $i++) {
// echo ord($a[$i]).' ';
// }
// echo "\n";
// for ($i=0; $i<strlen($b); $i++) {
// echo ord($b[$i]).' ';
// }

echo "\n\n";
$a2 = preg_split('/\r\n|\r|\n/', $a);
$b2 = preg_split('/\r\n|\r|\n/', $b);
Expand Down Expand Up @@ -93,7 +101,7 @@ private function runEach($name, $file, $isJson, $inputCr, $outputCr)
'eol' => $outputCr ? "\r\n" : "\n",
'emitRootBraces' => true,
'space' => 2
]);
]).($outputCr ? "\r" : "")."\n";
$result = json_decode($this->load("{$name}_result.json", $inputCr));
$text2 = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$this->assertEquals($text1, $text2);
Expand Down
2 changes: 1 addition & 1 deletion tests/assets/charset_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
ql-ascii: ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄäÅåÖöÉé
js-ascii: ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄäÅåÖöÉé
ml-ascii: ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄäÅåÖöÉé
}
}
2 changes: 1 addition & 1 deletion tests/assets/charset_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"ql-ascii": "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄäÅåÖöÉé",
"js-ascii": "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄäÅåÖöÉé",
"ml-ascii": "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄäÅåÖöÉé"
}
}
2 changes: 1 addition & 1 deletion tests/assets/comments_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
str1: 00 # part of the string
str2: 00.0 // part of the string
str3: 02 /* part of the string */
}
}
2 changes: 1 addition & 1 deletion tests/assets/comments_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"str1": "00 # part of the string",
"str2": "00.0 // part of the string",
"str3": "02 /* part of the string */"
}
}
2 changes: 1 addition & 1 deletion tests/assets/empty_result.hjson
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"": empty
}
}
2 changes: 1 addition & 1 deletion tests/assets/empty_result.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"": "empty"
}
}
2 changes: 1 addition & 1 deletion tests/assets/failJSON02_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Unclosed array"
["Unclosed array"
2 changes: 1 addition & 1 deletion tests/assets/failJSON05_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["double extra comma",,]
["double extra comma",,]
2 changes: 1 addition & 1 deletion tests/assets/failJSON06_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ , "<-- missing value"]
[ , "<-- missing value"]
2 changes: 1 addition & 1 deletion tests/assets/failJSON07_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Comma after the close"],
["Comma after the close"],
2 changes: 1 addition & 1 deletion tests/assets/failJSON08_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Extra close"]]
["Extra close"]]
2 changes: 1 addition & 1 deletion tests/assets/failJSON10_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Extra value after close": true} "misplaced quoted value"
{"Extra value after close": true} "misplaced quoted value"
2 changes: 1 addition & 1 deletion tests/assets/failJSON11_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Illegal expression": 1 + 2}
{"Illegal expression": 1 + 2}
2 changes: 1 addition & 1 deletion tests/assets/failJSON12_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Illegal invocation": alert()}
{"Illegal invocation": alert()}
2 changes: 1 addition & 1 deletion tests/assets/failJSON13_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Numbers cannot have leading zeroes": 013}
{"Numbers cannot have leading zeroes": 013}
2 changes: 1 addition & 1 deletion tests/assets/failJSON14_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Numbers cannot be hex": 0x14}
{"Numbers cannot be hex": 0x14}
2 changes: 1 addition & 1 deletion tests/assets/failJSON15_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Illegal backslash escape: \x15"]
["Illegal backslash escape: \x15"]
2 changes: 1 addition & 1 deletion tests/assets/failJSON16_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[\naked]
[\naked]
2 changes: 1 addition & 1 deletion tests/assets/failJSON17_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Illegal backslash escape: \017"]
["Illegal backslash escape: \017"]
2 changes: 1 addition & 1 deletion tests/assets/failJSON19_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Missing colon" null}
{"Missing colon" null}
2 changes: 1 addition & 1 deletion tests/assets/failJSON20_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Double colon":: null}
{"Double colon":: null}
2 changes: 1 addition & 1 deletion tests/assets/failJSON21_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Comma instead of colon", null}
{"Comma instead of colon", null}
2 changes: 1 addition & 1 deletion tests/assets/failJSON22_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Colon instead of comma": false]
["Colon instead of comma": false]
2 changes: 1 addition & 1 deletion tests/assets/failJSON23_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Bad value", truth]
["Bad value", truth]
2 changes: 1 addition & 1 deletion tests/assets/failJSON26_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["tab\ character\ in\ string\ "]
["tab\ character\ in\ string\ "]
2 changes: 1 addition & 1 deletion tests/assets/failJSON28_test.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
["line\
break"]
break"]
2 changes: 1 addition & 1 deletion tests/assets/failJSON29_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0e]
[0e]
2 changes: 1 addition & 1 deletion tests/assets/failJSON30_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0e+]
[0e+]
2 changes: 1 addition & 1 deletion tests/assets/failJSON31_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0e+-1]
[0e+-1]
2 changes: 1 addition & 1 deletion tests/assets/failJSON32_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Comma instead if closing brace": true,
{"Comma instead if closing brace": true,
2 changes: 1 addition & 1 deletion tests/assets/failJSON33_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["mismatch"}
["mismatch"}
2 changes: 1 addition & 1 deletion tests/assets/failJSON35_test.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
:0
}
}
2 changes: 1 addition & 1 deletion tests/assets/kan_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
null null
x null
]
}
}
2 changes: 1 addition & 1 deletion tests/assets/kan_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"null null",
"x null"
]
}
}
2 changes: 1 addition & 1 deletion tests/assets/keys_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
nl1: test
nl2: test
nl3: test
}
}
2 changes: 1 addition & 1 deletion tests/assets/keys_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"nl1": "test",
"nl2": "test",
"nl3": "test"
}
}
2 changes: 1 addition & 1 deletion tests/assets/large_file_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -1799,4 +1799,4 @@
value: value300
other: other300
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/large_file_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -1499,4 +1499,4 @@
"value": "value300",
"other": "other300"
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/large_file_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1499,4 +1499,4 @@
"value": "value300",
"other": "other300"
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/oa_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
d: {}
}
[]
]
]
2 changes: 1 addition & 1 deletion tests/assets/oa_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"d": {}
},
[]
]
]
2 changes: 1 addition & 1 deletion tests/assets/pass1_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
2
2
rosebud
]
]
2 changes: 1 addition & 1 deletion tests/assets/pass1_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
2,
2,
"rosebud"
]
]
2 changes: 1 addition & 1 deletion tests/assets/pass1_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
0.1e1,
1e-1,
1e00,2e+00,2e-00
,"rosebud"]
,"rosebud"]
2 changes: 1 addition & 1 deletion tests/assets/pass2_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
]
]
]
]
]
2 changes: 1 addition & 1 deletion tests/assets/pass2_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
]
]
]
]
]
2 changes: 1 addition & 1 deletion tests/assets/pass2_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
2 changes: 1 addition & 1 deletion tests/assets/pass3_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"The outermost value": must be an object or array.
"In this test": It is an object.
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/pass3_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"The outermost value": "must be an object or array.",
"In this test": "It is an object."
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/pass4_result.hjson
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
10
2 changes: 1 addition & 1 deletion tests/assets/pass4_result.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
10
2 changes: 1 addition & 1 deletion tests/assets/passSingle_result.hjson
Original file line number Diff line number Diff line change
@@ -1 +1 @@
allow quoteless strings
allow quoteless strings
2 changes: 1 addition & 1 deletion tests/assets/passSingle_result.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"allow quoteless strings"
"allow quoteless strings"
2 changes: 1 addition & 1 deletion tests/assets/passSingle_test.hjson
Original file line number Diff line number Diff line change
@@ -1 +1 @@
allow quoteless strings
allow quoteless strings
2 changes: 1 addition & 1 deletion tests/assets/root_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
host: 127.0.0.1
port: 555
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/root_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"host": "127.0.0.1",
"port": 555
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/stringify1_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
comment2: a//str
comment3: a/*str*/
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/stringify1_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"comment2": "a//str",
"comment3": "a/*str*/"
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/strings2_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
foo3b: "'''asdf"
foo4a: "asdf'''\nasdf"
foo4b: "asdf\n'''asdf"
}
}
2 changes: 1 addition & 1 deletion tests/assets/strings2_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"foo3b": "'''asdf",
"foo4a": "asdf'''\nasdf",
"foo4b": "asdf\n'''asdf"
}
}
2 changes: 1 addition & 1 deletion tests/assets/strings_result.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
minus: "-3"
zero: "0"
}
}
}
2 changes: 1 addition & 1 deletion tests/assets/strings_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
"minus": "-3",
"zero": "0"
}
}
}
Loading