4 ms·
> const p1 = {x: 2, y: 3}; > const p2 = {x: 2, y: 3}; > assert.notEqual(p1,p2); // NOT what I want > Sadly that test passes. It does so because JavaScript t
by dmalvarado 10y ago
> const p1 = {x: 2, y: 3};
> const p2 = {x: 2, y: 3};
> assert.notEqual(p1,p2); // NOT what I want
> Sadly that test passes. It does so because JavaScript tests equality for js objects by looking at their references, ignoring the values they contain.
What? Has 'assert' been standardized?
Shouldn't it read: "It does so because my assert function tests equality for js objects by looking at their references, ignoring the values they contain."
- mcbits 10y agoI think his point would be the same (and maybe clearer) if he said assert.isFalse(p1 == p2). I.e. he's not concerned about the testing semantics, but JavaScript's equality semantics which we're expected to assume the test function is using.
- deleted 10y ago[deleted]