power-assert-js/power-assert

BigNumber support

miohtama opened this issue · 0 comments

What would be tests needed to support BigNumber comparison in power-assert? BigNumber is userful in cryptography, finance and blockchain.

Currently comparing BigNumbers works if you stringify them first

assert(supply.toString() == TOKEN_1ST_TOTAL_SUPPLY.toString());

But this comparison of BigNumber objects fails

assert(supply == TOKEN_1ST_TOTAL_SUPPLY);

Output:


      AssertionError [ERR_ASSERTION]:   # Token.spec.ts:11
  
  assert(supply == TOKEN_1ST_TOTAL_SUPPLY)
         |      |  |                      
         |      |  BN{negative:0,words:#Array#,length:4,red:null}
         |      false                     
         BN{negative:0,words:#Array#,length:4,red:null}
  
  [BN] TOKEN_1ST_TOTAL_SUPPLY
  => BN{negative:0,words:#Array#,length:4,red:null}
  [BN] supply
  => BN{negative:0,words:#Array#,length:4,red:null}