Skip to content

Commit 44d5bce

Browse files
committed
Use strict equality in formulas
1 parent 57f36ce commit 44d5bce

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/formula.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ class BinaryOperation extends Expression {
8282
"**": Math.pow,
8383

8484
// Logical
85-
"!=": (x, y) => x != y,
86-
// TODO: Should this use triple equals?
87-
"==": (x, y) => x == y,
85+
"!=": (x, y) => x !== y,
86+
"==": (x, y) => x === y,
8887
">=": (x, y) => x >= y,
8988
">": (x, y) => x > y,
9089
"<=": (x, y) => x <= y,

test/sheet-and-formula.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,8 @@ test("Cells with empty formula have undefined value", async () => {
374374
state.currentSheet.cells[0][1].formula = "";
375375
await expectSheet(state.currentSheet, [[undefined, undefined]]);
376376
});
377+
378+
test("Formulas use strict equality", async () => {
379+
const state = createSheet([[`=10 == "10"`, `="1" != 1`]]);
380+
await expectSheet(state.currentSheet, [[false, true]]);
381+
});

0 commit comments

Comments
 (0)