Skip to content

Commit

Permalink
Updated Bool function to evaluate 'false' (#4320)
Browse files Browse the repository at this point in the history
Co-authored-by: Emiliano Quiroga <emiliano.quiroga@7-11.com>
  • Loading branch information
sw-joelmut and Emiliano Quiroga authored Sep 9, 2022
1 parent 403b4f7 commit a7b90f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libraries/adaptive-expressions/src/builtinFunctions/bool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class Bool extends ComparisonEvaluator {
return args[0] !== 0;
}

if (/false/i.test(args[0])) {
return false;
}

return InternalFunctionUtils.isLogicTrue(args[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ const testCases = [
['bool(0)', false],
['bool(null)', false],
['bool(hello * 5)', false],
["bool('false')", true], // we make it true, because it is not empty
["bool('false')", false],
["bool('true')", true],
["bool('hi')", true],
['[1,2,3]', [1, 2, 3]],
['[1,2,3, [4,5]]', [1, 2, 3, [4, 5]]],
Expand Down

0 comments on commit a7b90f3

Please sign in to comment.