Fix property chain orders of Operators in isDotExpression and isSomPredicate
This commit is contained in:
parent
2146d93609
commit
22cc9b7dc7
@ -661,14 +661,14 @@ class AstBinaryOperator extends Leaf {
|
||||
}
|
||||
|
||||
isDotExpression() {
|
||||
return Operators.id.dot <= this.id && this.id <= Operators.id.dotHash;
|
||||
return Operators.dot.id <= this.id && this.id <= Operators.dotHash.id;
|
||||
}
|
||||
|
||||
isSomPredicate() {
|
||||
return (
|
||||
this.isDotExpression() ||
|
||||
(Operators.id.lt <= this.id &&
|
||||
this.id <= Operators.id.or &&
|
||||
(Operators.lt.id <= this.id &&
|
||||
this.id <= Operators.or.id &&
|
||||
((this.left.isDotExpression() && this.right.isConstant()) ||
|
||||
(this.left.isConstant() && this.right.isDotExpression()) ||
|
||||
(this.left.isDotExpression() && this.right.isDotExpression())))
|
||||
|
@ -266,7 +266,9 @@ describe("FormCalc expression parser", function () {
|
||||
|
||||
it("should parse basic expression with dots", function () {
|
||||
const parser = new Parser("a.b.c.#d..e.f..g.*");
|
||||
expect(parser.parse().dump()[0]).toEqual({
|
||||
const exprlist = parser.parse();
|
||||
expect(exprlist.expressions[0].isDotExpression()).toEqual(true);
|
||||
expect(exprlist.dump()[0]).toEqual({
|
||||
operator: ".",
|
||||
left: { id: "a" },
|
||||
right: {
|
||||
@ -727,5 +729,12 @@ endfunc
|
||||
);
|
||||
expect(() => parser.parse()).toThrow(new Error(Errors.if));
|
||||
});
|
||||
|
||||
it("should parse som predicate", () => {
|
||||
const parser = new Parser("a.b <= 3");
|
||||
const expr = parser.parse().expressions[0];
|
||||
expect(expr.isSomPredicate()).toEqual(true);
|
||||
expect(expr.left.isSomPredicate()).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user