diff --git a/package.json b/package.json index 3ee4067..4543acd 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Exp.js b/src/Exp.js index 15556e8..82c338a 100644 --- a/src/Exp.js +++ b/src/Exp.js @@ -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') { diff --git a/test/2-bug-fix-test.js b/test/2-bug-fix-test.js index 66ab593..702c6e8 100644 --- a/test/2-bug-fix-test.js +++ b/test/2-bug-fix-test.js @@ -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 };