Skip to content

Commit

Permalink
fix: ensure that symbol args as message don't break assert.compareArray
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron authored and jugglinmike committed Oct 5, 2021
1 parent 12e9d67 commit addfd8b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions harness/compareArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ compareArray.format = function(arrayLike) {

assert.compareArray = function(actual, expected, message) {
message = message === undefined ? '' : message;

if (typeof message === 'symbol') {
message = message.toString();
}

assert(actual != null, `First argument shouldn't be nullish. ${message}`);
assert(expected != null, `Second argument shouldn't be nullish. ${message}`);
var format = compareArray.format;
Expand Down
23 changes: 23 additions & 0 deletions test/harness/compare-array-message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: >
compareArray can handle any value in message arg
includes: [compareArray.js]
features: [BigInt, Symbol]
---*/

assert.compareArray([], [], true);
assert.compareArray([], [], 1);
assert.compareArray([], [], 1n);
assert.compareArray([], [], () => {});
assert.compareArray([], [], "test262");
assert.compareArray([], [], Symbol("1"));
assert.compareArray([], [], {});
assert.compareArray([], [], []);
assert.compareArray([], [], -1);
assert.compareArray([], [], Infinity);
assert.compareArray([], [], -Infinity);
assert.compareArray([], [], 0.1);
assert.compareArray([], [], -0.1);

0 comments on commit addfd8b

Please sign in to comment.