Skip to content

Commit

Permalink
- Add test case for non-quoted keyword (d3x0r#44)
Browse files Browse the repository at this point in the history
- Strip trailing whitespace
  • Loading branch information
brettz9 committed Jul 12, 2020
1 parent cce1dd3 commit 770e7bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ If you make notable improvments/fixes I would appreciate a best effort to share
such changes; or at least share that there might be a possibility of improvement.
There is no penalty if nothing is shared. I attempted to get JSON5 maintainers
to implement the changes before re-implementing, but they were unresponsive.
Besides this implementation is twice the speed, so it benefits a lot from not
Besides this implementation is twice the speed, so it benefits a lot from not
being based on their code in the first place. It's only based on the description
of their extensions to original JSON format.
of their extensions to original JSON format.
7 changes: 6 additions & 1 deletion test/json6Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ describe('Basic parsing', function () {
//console.log( "o is", o );
expect(o).to.deep.equal({ a: 'abcdef' });
});
it('Unquoted non-keyword', function () {
const o = parse( "{ op:'update' }" );
//console.log( "o is", o );
expect(o).to.deep.equal({ op: 'update' });
});
it('Unquoted keyword (true)', function () {
const o = parse( "{ true:1 }" );
//console.log( "o is", o );
Expand Down Expand Up @@ -323,7 +328,7 @@ describe('Parsing with reviver', function () {
const results = [];
const o = parse( "{\"a\":{\"b\":{\"c\":{\"d\":123}, e:456}, f:789}, g: 987}", function (a, b) {
results.push([a, b]);
//console.log( a, b );
//console.log( a, b );
return b;
} );
//console.log( "o is", JSON.stringify( o ) );
Expand Down
4 changes: 2 additions & 2 deletions test/json6_internals_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('JSON6.streaming.internal', function () {
parseResult = parser._write( "1 2 3 4 5 " );
results.push( parseResult );
results.push( parser.value() );

parseResult = parser._write( "1 2 3 " );
parseResult = parser._write();
results.push( parseResult );
Expand All @@ -27,7 +27,7 @@ describe('JSON6.streaming.internal', function () {
while( (parseResult = parser._write()) ) {
//console.log( "Leftover Data:", parser.value() );
}

// and now, there will be a 'saved' which push() can pull from.
parseResult = parser._write( "1 " );
//console.log( "Leftover Data:", parser.value() );
Expand Down

0 comments on commit 770e7bc

Please sign in to comment.