mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-21 10:05:34 +08:00
fix(parse): fix operators associativity
Make the operators `&&`, `==`, `!=`, `===`, `!==`, `<`, `>`, `<=`, `>=` follow Javascript left-to-right associativity
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user