Getters for math expression properties

This commit is contained in:
Tim Schaub
2013-06-11 22:55:13 -06:00
parent 4a617871da
commit 2528581642
2 changed files with 49 additions and 0 deletions

View File

@@ -521,6 +521,33 @@ ol.expression.Math.prototype.evaluate = function(opt_scope, opt_fns, opt_this) {
};
/**
* Get the math operator.
* @return {string} The math operator.
*/
ol.expression.Math.prototype.getOperator = function() {
return this.operator_;
};
/**
* Get the left expression.
* @return {ol.expression.Expression} The left expression.
*/
ol.expression.Math.prototype.getLeft = function() {
return this.left_;
};
/**
* Get the right expression.
* @return {ol.expression.Expression} The right expression.
*/
ol.expression.Math.prototype.getRight = function() {
return this.right_;
};
/**
* A member expression (e.g. `foo.bar`).

View File

@@ -510,6 +510,28 @@ describe('ol.expression.Math', function() {
});
});
var op = ol.expression.MathOp.MOD;
var left = new ol.expression.Identifier('foo');
var right = new ol.expression.Literal(20);
var expr = new ol.expression.Math(op, left, right);
describe('#getOperator()', function() {
it('gets the operator', function() {
expect(expr.getOperator()).to.be(op);
});
});
describe('#getLeft()', function() {
it('gets the left expression', function() {
expect(expr.getLeft()).to.be(left);
});
});
describe('#getRight()', function() {
it('gets the right expression', function() {
expect(expr.getRight()).to.be(right);
});
});
});