commit
f94221a37f
@ -360,6 +360,7 @@ var Lexer = (function LexerClosure() {
|
|||||||
do {
|
do {
|
||||||
ch = stream.getChar();
|
ch = stream.getChar();
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case null:
|
||||||
case undefined:
|
case undefined:
|
||||||
warn('Unterminated string');
|
warn('Unterminated string');
|
||||||
done = true;
|
done = true;
|
||||||
@ -378,6 +379,7 @@ var Lexer = (function LexerClosure() {
|
|||||||
case '\\':
|
case '\\':
|
||||||
ch = stream.getChar();
|
ch = stream.getChar();
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case null:
|
||||||
case undefined:
|
case undefined:
|
||||||
warn('Unterminated string');
|
warn('Unterminated string');
|
||||||
done = true;
|
done = true;
|
||||||
@ -427,10 +429,12 @@ var Lexer = (function LexerClosure() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
str += ch;
|
str += ch;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
str += ch;
|
str += ch;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
return str;
|
return str;
|
||||||
|
@ -14,6 +14,19 @@ describe('parser', function() {
|
|||||||
expect(result).toEqual(11.234);
|
expect(result).toEqual(11.234);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should stop parsing strings at the end of stream', function() {
|
||||||
|
var input = new StringStream('1$4)');
|
||||||
|
input.getChar = function(super_getChar) {
|
||||||
|
// simulating end of file using null (see issue 2766)
|
||||||
|
var ch = super_getChar.call(input);
|
||||||
|
return ch == '$' ? null : ch;
|
||||||
|
}.bind(input, input.getChar);
|
||||||
|
var lexer = new Lexer(input);
|
||||||
|
var result = lexer.getString();
|
||||||
|
|
||||||
|
expect(result).toEqual('1');
|
||||||
|
});
|
||||||
|
|
||||||
it('should not throw exception on bad input', function() {
|
it('should not throw exception on bad input', function() {
|
||||||
// '8 0 2 15 5 2 2 2 4 3 2 4'
|
// '8 0 2 15 5 2 2 2 4 3 2 4'
|
||||||
// should be parsed as
|
// should be parsed as
|
||||||
|
Loading…
Reference in New Issue
Block a user