Closed rameshrajagopalanbayer closed 1 year ago
assert with two parameters or assert.equal is used for comparing primitive values or for checking the equality of object references (not their content).
assert.deepEqual, compares the properties and values within the objects recursively to check if they are equal.
So if we have places where we compare objects without using deepEqual, that is a problem
On the equal for example on Test397.js (https://github.com/AlaSQL/alasql/blob/develop/test/test397.js) , I can change the expected value to anything and the test still pass afaict.
Line 22 Fails after expected value change to be incorrect
var res = alasql('= 256 >> 4');
assert.equal(res, 56);
vs
Does not fail the test with incorrect expected
var res = alasql('= 256 >> 4');
assert(res, 56);
The deep equal on objects is where i first saw the issue for sure. If you can please take a look at above one even, when you get a chance and let me know I can make a PR for above. Also fwiw i tried on node 16 not sure that make any diff and this assert functionality was changed in later versions of node.
This is terrible!
We got 58 examples of this.
It gave 10 errors after fixing them. I will have to look into this.
@rameshrajagopalanbayer Thank you for reporting this.
As I worked on https://github.com/AlaSQL/alasql/pull/1794 I noticed there are a few specs which follow pattern of
assert(res,
They seem to pass even when i changed the expected values.I made a change on the one test in that PR(https://github.com/AlaSQL/alasql/pull/1794/files#diff-45ecd1e6cf603c0d570eae55d8803c4b5af8e3aee3d64d1b061d64814191e146R19).
Should the other specs like shown in this branch https://github.com/AlaSQL/alasql/compare/develop...rameshrajagopalanbayer:alasql:asserts-fix?expand=1 also have the equal or deepEqual added to it,
If this looks to be the case let me know i can make that change and create a PR. Currently i do have 1 spec (uncomment) fail after the change to have equal or deepEqual.