New ThisIdentifier expression

This allows member expressions to use the 'this' keyword.
This commit is contained in:
ahocevar
2013-08-20 23:15:05 +02:00
parent 89052079b7
commit 4f2d37b6a3
5 changed files with 64 additions and 1 deletions

View File

@@ -92,6 +92,12 @@ describe('ol.expr.parse()', function() {
expect(expr.evaluate(scope)).to.be(42);
});
it('parses member expressions in the \'this\' scope', function() {
var expr = ol.expr.parse('this.foo');
var thisScope = {foo: 'bar'};
expect(expr.evaluate(undefined, undefined, thisScope)).to.be('bar');
});
it('consumes whitespace as expected', function() {
var expr = ol.expr.parse(' foo . bar . baz ');
expect(expr).to.be.a(ol.expr.Member);