Skip to content

Commit

Permalink
[PORT][Expression]fix null check in expression (#2118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danieladu authored Apr 28, 2020
1 parent a26c719 commit 18cb982
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libraries/adaptive-expressions/src/expressionFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1838,8 +1838,8 @@ export class ExpressionFunctions {
return false;
}

if (args[0] === undefined || args[0] === null) {
return args[1] === undefined || args[1] === null;
if (args[0] === undefined || args[0] === null || args[1] === undefined || args[1] === null) {
return (args[0] === undefined || args[0] === null) && (args[1] === undefined || args[1] === null);
}

if (Array.isArray(args[0]) && args[0].length === 0 && Array.isArray(args[1]) && args[1].length === 0) {
Expand Down
15 changes: 13 additions & 2 deletions libraries/adaptive-expressions/tests/expressionParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,18 @@ const dataSource = [
['emptyList == { }', false],
['emptyObject == { }', true],
['emptyObject == [ ]', false],

['{} == undefined', false],
['{} != undefined', true],
['[] == undefined', false],
['{} != undefined', true],
['{} == null', false],
['{} != null', true],
['[] == null', false],
['{} != null', true],
['{} == {}', true],
['[] == []', true],
['{} != []', true],
['[] == {}', false],

// Conversion functions tests
['float(\'10.333\')', 10.333],
Expand Down Expand Up @@ -632,7 +643,7 @@ const dataSource = [
];

const scope = {
"$index": "index",
'$index': 'index',
alist: [
{
Name: 'item1'
Expand Down

0 comments on commit 18cb982

Please sign in to comment.