Illegal expression in contains

This commit is contained in:
ChenL
2017-03-15 20:38:08 +08:00
parent ea7e334d87
commit 7ad9ce95e9
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ var operators = {
'<': (l, r) => l < r,
'>=': (l, r) => l >= r,
'<=': (l, r) => l <= r,
'contains': (l, r) => l.indexOf(r) > -1,
'contains': (l, r) => typeof l === 'string' ? l.indexOf(r) > -1 : false,
'and': (l, r) => l && r,
'or': (l, r) => l || r
};
+3 -1
View File
@@ -13,7 +13,8 @@ describe('expression', function() {
scope = Scope.factory({
one: 1,
two: 2,
x: 'XXX'
x: 'XXX',
y: undefined
});
});
@@ -25,6 +26,7 @@ describe('expression', function() {
it('should throw on illegal expression', function() {
expect(function() {
evalExp('1 contains "x"', scope);
evalExp('y contains "x"', scope);
}).to.throw();
});