Expectations about token type
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
goog.provide('ol.expression.Lexer');
|
||||
goog.provide('ol.expression.TokenType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
|
||||
|
||||
@@ -19,36 +19,43 @@ describe('ol.expression.Lexer', function() {
|
||||
it('works for integers', function() {
|
||||
var token = scan('123');
|
||||
expect(token.value).to.be(123);
|
||||
expect(token.type).to.be(ol.expression.TokenType.NUMERIC_LITERAL);
|
||||
});
|
||||
|
||||
it('works for float', function() {
|
||||
var token = scan('123.456');
|
||||
expect(token.value).to.be(123.456);
|
||||
expect(token.type).to.be(ol.expression.TokenType.NUMERIC_LITERAL);
|
||||
});
|
||||
|
||||
it('works with exponent', function() {
|
||||
var token = scan('1.234e5');
|
||||
expect(token.value).to.be(1.234e5);
|
||||
expect(token.type).to.be(ol.expression.TokenType.NUMERIC_LITERAL);
|
||||
});
|
||||
|
||||
it('works with explicit positive exponent', function() {
|
||||
var token = scan('1.234e+5');
|
||||
expect(token.value).to.be(1.234e5);
|
||||
expect(token.type).to.be(ol.expression.TokenType.NUMERIC_LITERAL);
|
||||
});
|
||||
|
||||
it('works with negative exponent', function() {
|
||||
var token = scan('1.234e-5');
|
||||
expect(token.value).to.be(1.234e-5);
|
||||
expect(token.type).to.be(ol.expression.TokenType.NUMERIC_LITERAL);
|
||||
});
|
||||
|
||||
it('works with octals', function() {
|
||||
var token = scan('02322');
|
||||
expect(token.value).to.be(1234);
|
||||
expect(token.type).to.be(ol.expression.TokenType.NUMERIC_LITERAL);
|
||||
});
|
||||
|
||||
it('works with hex', function() {
|
||||
var token = scan('0x4d2');
|
||||
expect(token.value).to.be(1234);
|
||||
expect(token.type).to.be(ol.expression.TokenType.NUMERIC_LITERAL);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -56,3 +63,4 @@ describe('ol.expression.Lexer', function() {
|
||||
});
|
||||
|
||||
goog.require('ol.expression.Lexer');
|
||||
goog.require('ol.expression.TokenType');
|
||||
|
||||
Reference in New Issue
Block a user