File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,22 @@ exports['test extra brace'] = function () {
259
259
assert [ 'throws' ] ( function ( ) { parse ( json ) } , 'should throw error' )
260
260
}
261
261
262
+ exports [ 'test error location with Windows line breaks' ] = function ( ) {
263
+ var json = '{\r\n"foo": {\r\n "bar":\r\n }\r\n \r\n }'
264
+ try {
265
+ parse ( json )
266
+ assert . fail ( 'should throw error' )
267
+ } catch ( error ) {
268
+ assert . equal ( error . exzerpt , '... "bar": } }' )
269
+ assert . equal ( error . pointer , '-------------------^' )
270
+ assert . equal ( error . reason , 'Unexpected token }' )
271
+ assert . equal ( error . message , 'Parse error on line 4, column 5:\n... "bar": } }\n-------------------^\nUnexpected token }' )
272
+ assert . deepEqual ( error . location , {
273
+ start : { column : 5 , line : 4 , offset : 31 }
274
+ } )
275
+ }
276
+ }
277
+
262
278
exports [ 'test pass-1' ] = function ( ) {
263
279
var json = fs . readFileSync ( path . join ( __dirname , '/passes/1.json' ) ) . toString ( )
264
280
assert . doesNotThrow ( function ( ) { parse ( json ) } , 'should pass' )
You can’t perform that action at this time.
0 commit comments