From 8cb7f593950a77e3a17b520fea5ec9414a56879b Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg <littledan@chromium.org> Date: Tue, 25 Apr 2017 16:06:15 +0200 Subject: [PATCH] Create an assert.compareArray This is a convenience function which tries to make tests easier to read and write. --- harness/compareArray.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/harness/compareArray.js b/harness/compareArray.js index 6eb69e6eba..0e0654aeb4 100644 --- a/harness/compareArray.js +++ b/harness/compareArray.js @@ -13,3 +13,17 @@ function compareArray(a, b) { return true; } +assert.compareArray = function(actual, expected, message) { + if (compareArray(actual, expected)) return; + + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + String(actual) + '», «' + String(expected) + '») to be true'; + + $ERROR(`${message}${message === undefined ? '' : ' '}Expected the arrays [${actual}] to have the same contents as [${expected}]`); +} -- GitLab