Skip to content

Commit

Permalink
fix: strict equals #87
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiooshiro committed Nov 2, 2022
1 parent 6925552 commit b60e928
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xlsx-calc",
"version": "0.7.5",
"version": "0.7.6",
"description": "A simple xlsx formula calculator.",
"main": "src/index.js",
"repository": "git@github.com:fabiooshiro/xlsx-calc.git",
Expand Down
2 changes: 1 addition & 1 deletion src/Exp.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module.exports = function Exp(formula) {
if (typeof a === 'string' && typeof b === 'string' && a.toLowerCase() === b.toLowerCase()) {
return true;
}
return a == b;
return a === b;
});
if (args.length == 1) {
if (typeof(args[0].calc) !== 'function') {
Expand Down
10 changes: 10 additions & 0 deletions test/2-bug-fix-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ describe('Bugs', function() {
XLSX_CALC(workbook);
assert.equal(workbook.Sheets.Sheet1.A1.v, 24);
});
it('should calc 0="" as false', function() {
workbook.Sheets.Sheet1.A1.f = '0=""';
XLSX_CALC(workbook);
assert.equal(workbook.Sheets.Sheet1.A1.v, false);
});
it('should calc 0<>"" as true', function() {
workbook.Sheets.Sheet1.A2.f = '0<>""';
XLSX_CALC(workbook);
assert.equal(workbook.Sheets.Sheet1.A2.v, true);
});
it('should consider the end of string', function() {
workbook.Sheets.Sheet1.A1.f = 'IF($C$3<=0,"Tempo de Investimento Invalido",IF($C$3<=24,"x","y"))';
workbook.Sheets.Sheet1.C3 = { v: 24 };
Expand Down

0 comments on commit b60e928

Please sign in to comment.