diff options
Diffstat (limited to 'tests/wpt/web-platform-tests/common/arrays.js')
-rw-r--r-- | tests/wpt/web-platform-tests/common/arrays.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/common/arrays.js b/tests/wpt/web-platform-tests/common/arrays.js new file mode 100644 index 00000000000..49431dd78ad --- /dev/null +++ b/tests/wpt/web-platform-tests/common/arrays.js @@ -0,0 +1,16 @@ +// Returns true if the given arrays are equal. Optionally can pass an equality function. +export function areArraysEqual(a, b, equalityFunction = (c, d) => { return c === d; }) { + try { + if (a.length !== b.length) + return false; + + for (let i = 0; i < a.length; i++) { + if (!equalityFunction(a[i], b[i])) + return false; + } + } catch (ex) { + return false; + } + + return true; +} |