Skip to content

Commit

Permalink
Remove assert.deepEqual
Browse files Browse the repository at this point in the history
The `assert.deepEqual` utility method was originally implemented in
support of two tests for the "RegExp Match Indices" proposal [1]. In the
years since that time, it has been referenced by one additional test,
where it is interchangeable with the considerably simpler
`assert.compareArray`.

Refactor the RegExp tests to use a simpler inline helper function that
verifies the same semantics and preserves meaningful error messages.

[1] tc39#2309
  • Loading branch information
jugglinmike committed Sep 18, 2021
1 parent 16dae73 commit fc81738
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 472 deletions.
327 changes: 0 additions & 327 deletions harness/deepEqual.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/built-ins/Error/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ info: |
esid: sec-error-message
features: [error-cause]
includes: [deepEqual.js]
includes: [compareArray.js]
---*/

var message = "my-message";
Expand All @@ -34,4 +34,4 @@ new Error(
},
);

assert.deepEqual(sequence, [ "toString", "cause" ], "accessing own properties on sequence");
assert.compareArray(sequence, [ "toString", "cause" ], "accessing own properties on sequence");
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/*---
description: Basic matching cases with non-unicode matches.
includes: [compareArray.js, propertyHelper.js, deepEqual.js]
includes: [compareArray.js, propertyHelper.js]
esid: sec-regexpbuiltinexec
features: [regexp-match-indices]
info: |
Expand Down Expand Up @@ -31,13 +31,21 @@ info: |
b. Perform ! CreateDataProperty(_A_, `"indices"`, _indicesArray_).
---*/

assert.deepEqual([[1, 2], [1, 2]], "bab".match(/(a)/d).indices);
assert.deepEqual([[0, 3], [1, 2]], "bab".match(/.(a)./d).indices);
assert.deepEqual([[0, 3], [1, 2], [2, 3]], "bab".match(/.(a)(.)/d).indices);
assert.deepEqual([[0, 3], [1, 3]], "bab".match(/.(\w\w)/d).indices);
assert.deepEqual([[0, 3], [0, 3]], "bab".match(/(\w\w\w)/d).indices);
assert.deepEqual([[0, 3], [0, 2], [2, 3]], "bab".match(/(\w\w)(\w)/d).indices);
assert.deepEqual([[0, 2], [0, 2], undefined], "bab".match(/(\w\w)(\W)?/d).indices);
function spread(indices) {
if (indices.length === 2) {
return indices[0].concat("x").concat(indices[1]);
} else if (indices.length === 3) {
return indices[0].concat("x").concat(indices[1]).concat("x").concat(indices[2]);
}
}

assert.compareArray([1, 2, "x", 1, 2], spread("bab".match(/(a)/d).indices));
assert.compareArray([0, 3, "x", 1, 2], spread("bab".match(/.(a)./d).indices));
assert.compareArray([0, 3, "x", 1, 2, "x", 2, 3], spread("bab".match(/.(a)(.)/d).indices));
assert.compareArray([0, 3, "x", 1, 3], spread("bab".match(/.(\w\w)/d).indices));
assert.compareArray([0, 3, "x", 0, 3], spread("bab".match(/(\w\w\w)/d).indices));
assert.compareArray([0, 3, "x", 0, 2, "x", 2, 3], spread("bab".match(/(\w\w)(\w)/d).indices));
assert.compareArray([0, 2, "x", 0, 2, "x", undefined], spread("bab".match(/(\w\w)(\W)?/d).indices));

let groups = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/d.exec("abccba").indices.groups;
assert.compareArray([0, 1], groups.a);
Expand Down
Loading

0 comments on commit fc81738

Please sign in to comment.