@@ -17,17 +17,35 @@ exports["test escaped chars"] = function () {
1717 assert . deepEqual ( parser . parse ( json ) , { "foo" : '\\\"' } ) ;
1818} ;
1919
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+
2025exports [ "test escaped \\n" ] = function ( ) {
2126 var json = '{"foo": "\\\\\\n"}' ;
2227 assert . deepEqual ( parser . parse ( json ) , { "foo" : '\\\n' } ) ;
2328} ;
2429
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+
2535exports [ "test string with escaped line break" ] = function ( ) {
2636 var json = '{"foo": "bar\\nbar"}' ;
2737 assert . deepEqual ( parser . parse ( json ) , { "foo" : "bar\nbar" } ) ;
2838 assert . equal ( JSON . stringify ( parser . parse ( json ) ) . length , 18 ) ;
2939} ;
3040
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+
3149exports [ "test string with line break" ] = function ( ) {
3250 var json = '{"foo": "bar\nbar"}' ;
3351 assert [ "throws" ] ( function ( ) { parser . parse ( json ) } , "should throw error" ) ;
0 commit comments