@@ -17,17 +17,35 @@ exports["test escaped chars"] = function () {
17
17
assert . deepEqual ( parser . parse ( json ) , { "foo" : '\\\"' } ) ;
18
18
} ;
19
19
20
+ exports [ "test all escaped characters" ] = function ( ) {
21
+ var json = '["\\u20AC","\\/","\\\\","\\b","\\f","\\n","\\r","\\t","\\\""]' ;
22
+ assert . deepEqual ( parser . parse ( json ) , [ '\u20AC' , '\/' , '\\' , '\b' , '\f' , '\n' , '\r' , '\t' , '\"' ] ) ;
23
+ } ;
24
+
20
25
exports [ "test escaped \\n" ] = function ( ) {
21
26
var json = '{"foo": "\\\\\\n"}' ;
22
27
assert . deepEqual ( parser . parse ( json ) , { "foo" : '\\\n' } ) ;
23
28
} ;
24
29
30
+ exports [ "test escaped backslash does not get used to escape" ] = function ( ) {
31
+ var json = '{"foo": "\\\\n"}' ;
32
+ assert . deepEqual ( parser . parse ( json ) , { "foo" : '\\n' } ) ;
33
+ } ;
34
+
25
35
exports [ "test string with escaped line break" ] = function ( ) {
26
36
var json = '{"foo": "bar\\nbar"}' ;
27
37
assert . deepEqual ( parser . parse ( json ) , { "foo" : "bar\nbar" } ) ;
28
38
assert . equal ( JSON . stringify ( parser . parse ( json ) ) . length , 18 ) ;
29
39
} ;
30
40
41
+ exports [ "test escaped value and key chars" ] = function ( ) {
42
+ var json = fs . readFileSync ( __dirname + "/passes/4.json" ) . toString ( ) ;
43
+ assert . deepEqual ( parser . parse ( json ) , {
44
+ hex : '\u0123\u4567\u89AB\uCDEF\uabcd\uef4A' ,
45
+ "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" : 'special char key'
46
+ } ) ;
47
+ } ;
48
+
31
49
exports [ "test string with line break" ] = function ( ) {
32
50
var json = '{"foo": "bar\nbar"}' ;
33
51
assert [ "throws" ] ( function ( ) { parser . parse ( json ) } , "should throw error" ) ;
0 commit comments