fix(parse): fix operators associativity

Make the operators `&&`, `==`, `!=`, `===`, `!==`, `<`, `>`, `<=`, `>=`
follow Javascript left-to-right associativity
This commit is contained in:
Lucas Galfaso
2014-11-23 14:06:45 +01:00
parent 3aa5752894
commit ed1243ffc7
2 changed files with 12 additions and 6 deletions

View File

@@ -276,6 +276,10 @@ describe('parser', function() {
expect(scope.$eval("2>=1")).toEqual(2 >= 1);
expect(scope.$eval("true==2<3")).toEqual(true == 2 < 3);
expect(scope.$eval("true===2<3")).toEqual(true === 2 < 3);
expect(scope.$eval("true===3===3")).toEqual(true === 3 === 3);
expect(scope.$eval("3===3===true")).toEqual(3 === 3 === true);
expect(scope.$eval("3 >= 3 > 2")).toEqual(3 >= 3 > 2);
});
it('should parse logical', function() {
@@ -703,6 +707,7 @@ describe('parser', function() {
throw "IT SHOULD NOT HAVE RUN";
};
expect(scope.$eval('false && run()')).toBe(false);
expect(scope.$eval('false && true && run()')).toBe(false);
});
it('should short-circuit OR operator', function() {
@@ -710,6 +715,7 @@ describe('parser', function() {
throw "IT SHOULD NOT HAVE RUN";
};
expect(scope.$eval('true || run()')).toBe(true);
expect(scope.$eval('true || false || run()')).toBe(true);
});