Skip to content

Commit

Permalink
Add several tests (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
Semigradsky committed Mar 11, 2023
1 parent bc8b3c7 commit eb76f52
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ Testing mixed objects not equal...
Caveats that impact the benchmark (and accuracy of comparison):

- `Map`s, `Promise`s, and `Set`s were excluded from the benchmark entirely because no library other than `deep-eql` fully supported their comparison
- `fast-deep-equal`, `react-fast-compare` and `nano-equal` throw on objects with `null` as prototype (`Object.create(null)`)
- `assert.deepStrictEqual` does not support `NaN` or `SameValueZero` equality for dates
- `deep-eql` does not support `SameValueZero` equality for zero equality (positive and negative zero are not equal)
- `deep-equal` does not support `NaN` and does not strictly compare object type, or date / regexp values, nor uses `SameValueZero` equality for dates
Expand Down
28 changes: 28 additions & 0 deletions __tests__/__helpers__/testSuites.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ export default [
value1: {},
value2: {},
},
{
deepEqual: true,
description: 'empty objects with `null` as prototype are equal',
shallowEqual: true,
value1: Object.create(null),
value2: Object.create(null),
},
{
deepEqual: true,
description: 'equal objects (same properties "order")',
Expand Down Expand Up @@ -393,6 +400,13 @@ export default [
},
value2: [0, 1],
},
{
deepEqual: false,
description: 'different sparse arrays are not equal',
shallowEqual: false,
value1: new Array(10),
value2: new Array(100),
},
],
},
{
Expand Down Expand Up @@ -611,6 +625,20 @@ export default [
{
description: 'typed arrays',
tests: [
{
deepEqual: true,
description: 'two empty arrays of the same class are equal',
shallowEqual: true,
value1: new Int32Array([]),
value2: new Int32Array([]),
},
{
deepEqual: false,
description: 'two empty arrays of the different class are not equal',
shallowEqual: false,
value1: new Int32Array([]),
value2: new Int16Array([]),
},
{
deepEqual: true,
description: 'equal Float32Array objects',
Expand Down
4 changes: 2 additions & 2 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ for (const name in packages) {
() => {
for (const test of testSuite.tests) {
if (
test.description !==
'pseudo array and equivalent array are not equal'
test.description !== 'pseudo array and equivalent array are not equal'
&& test.description !== 'empty objects with `null` as prototype are equal'
) {
fn(test.value1, test.value2);
}
Expand Down

0 comments on commit eb76f52

Please sign in to comment.