feat(CD): add support for === and !==

relates to #1500
This commit is contained in:
Victor Berchet 2015-05-19 12:02:40 +02:00
parent 6ec5d5daaf
commit 0ae89ac096
3 changed files with 20 additions and 1 deletions

View File

@ -67,6 +67,8 @@ export class ChangeDetectionUtil {
static operation_remainder(left, right) { return left % right; }
static operation_equals(left, right) { return left == right; }
static operation_not_equals(left, right) { return left != right; }
static operation_identical(left, right) { return left === right; }
static operation_not_identical(left, right) { return left !== right; }
static operation_less_then(left, right) { return left < right; }
static operation_greater_then(left, right) { return left > right; }
static operation_less_or_equals_then(left, right) { return left <= right; }

View File

@ -286,6 +286,10 @@ function _operationToPrimitiveName(operation: string): string {
return "operation_equals";
case '!=':
return "operation_not_equals";
case '===':
return "operation_identical";
case '!==':
return "operation_not_identical";
case '<':
return "operation_less_then";
case '>':
@ -319,6 +323,10 @@ function _operationToFunction(operation: string): Function {
return ChangeDetectionUtil.operation_equals;
case '!=':
return ChangeDetectionUtil.operation_not_equals;
case '===':
return ChangeDetectionUtil.operation_identical;
case '!==':
return ChangeDetectionUtil.operation_not_identical;
case '<':
return ChangeDetectionUtil.operation_less_then;
case '>':

View File

@ -168,8 +168,17 @@ export function main() {
expect(executeWatch('exp', '11 % 2')).toEqual(['exp=1']);
expect(executeWatch('exp', '1 == 1')).toEqual(['exp=true']);
if (IS_DARTIUM) {
expect(executeWatch('exp', '1 == "1"')).toEqual(['exp=false']);
} else {
expect(executeWatch('exp', '1 == "1"')).toEqual(['exp=true']);
}
expect(executeWatch('exp', '1 != 1')).toEqual(['exp=false']);
expect(executeWatch('exp', '1 === 1')).toEqual(['exp=true']);
expect(executeWatch('exp', '1 !== 1')).toEqual(['exp=false']);
expect(executeWatch('exp', '1 === "1"')).toEqual(['exp=false']);
expect(executeWatch('exp', '1 < 2')).toEqual(['exp=true']);
expect(executeWatch('exp', '2 < 1')).toEqual(['exp=false']);