Tape: missing comma can cause false positive

Created on 5 Sep 2018  路  4Comments  路  Source: substack/tape

I was amused to see this passing after I left a comma out:

test("foo", t => {
  t.deepEqual(
    [1,2]  // <-- notice a comma is missing after "]"
    [3]
  );
  t.end();
});

[3] becomes a property lookup for [1,2], returning undefined

t.deepEqual(undefined) is true.

__Proposing:__ t.deepEqual (et al) should fail if only one arg is passed.

breaking change

Most helpful comment

if(arguments.length < 2) throw 'one of those missing commas amirite?'

All 4 comments

whoa wtf

That's delightful, but if anyone was relying on the implicit undefined there, it'd be a breaking change. I'd be happy to make that change whenever we're doing a major otherwise, but I don't think it's worth it to do one just for that.

if(arguments.length < 2) throw 'one of those missing commas amirite?'

Since node's assert does this check, we can too in v5.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dcousens picture dcousens  路  3Comments

timbuckley picture timbuckley  路  5Comments

Istador picture Istador  路  3Comments

ralphtheninja picture ralphtheninja  路  6Comments

javajosh picture javajosh  路  5Comments