Skip to content

Commit

Permalink
fix: the formula of IS_ERROR is incorrectly calculated (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sky-FE committed Feb 21, 2023
1 parent 568c104 commit b939f9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/core/src/formula_parser/__tests__/logical.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ describe('Logical function test', () => {
// });

it('ISERROR', () => {
expect(evaluate(
'ISERROR(-1/{a})',
mergeContext({ a: 0, b: 'abc', c: 1591414562369, d: ['opt1', 'opt2'] }),
)).toEqual(true);

expect(evaluate(
'ISERROR({a}/{a})',
mergeContext({ a: 0, b: 'abc', c: 1591414562369, d: ['opt1', 'opt2'] }),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/formula_parser/functions/logical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export class IsError extends LogicalFunc {

static override func(params: [IFormulaParam<any>]): boolean {
const value = params[0].value;
const isError = value instanceof FormulaBaseError || isNaN(value) || value === Infinity;
const isError = value instanceof FormulaBaseError || isNaN(value) || value === Infinity || value === -Infinity;
return isError;
}
}

0 comments on commit b939f9d

Please sign in to comment.