Give token an index and throw unexpected token from a common place

This commit is contained in:
Tim Schaub
2013-06-12 14:52:31 -06:00
parent bb1b0cba95
commit 62eb0dd72b
4 changed files with 213 additions and 67 deletions

View File

@@ -378,7 +378,13 @@ describe('ol.expression.Lexer', function() {
it('throws on unterminated double quote', function() {
expect(function() {
scan('"never \'ending\' string');
}).to.throwException();
}).to.throwException(function(err) {
expect(err).to.be.an(Error);
var token = err.token;
expect(token).not.to.be(undefined);
expect(token.type).to.be(ol.expression.TokenType.EOF);
expect(token.index).to.be(22);
});
});
it('parses single quoted string', function() {
@@ -426,7 +432,13 @@ describe('ol.expression.Lexer', function() {
it('throws on unterminated single quote', function() {
expect(function() {
scan('\'never "ending" string');
}).to.throwException();
}).to.throwException(function(err) {
expect(err).to.be.an(Error);
var token = err.token;
expect(token).not.to.be(undefined);
expect(token.type).to.be(ol.expression.TokenType.EOF);
expect(token.index).to.be(22);
});
});
});