Debian Codegraph @

js/src/tests/test262/harness/compare-array-falsy-arguments.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: >
6 compareArray gracefully handles nullish arguments.
7 includes: [compareArray.js]
8 ---*/
9
10 function assertThrows(func, errorMessage) {
11 var caught = false;
12 try {
13 func();
14 } catch (error) {
15 caught = true;
16 assert.sameValue(error.constructor, Test262Error);
17 assert.sameValue(error.message, errorMessage);
18 }
19
20 assert(caught, `Expected ${func} to throw, but it didn't.`);
21 }
22
23 assertThrows(() => assert.compareArray(), "Actual argument shouldn't be nullish. ");
24 assertThrows(() => assert.compareArray(null, []), "Actual argument shouldn't be nullish. ");
25 assertThrows(() => assert.compareArray(null, [], "foo"), "Actual argument shouldn't be nullish. foo");
26
27 assertThrows(() => assert.compareArray([]), "Expected argument shouldn't be nullish. ");
28 assertThrows(() => assert.compareArray([], undefined, "foo"), "Expected argument shouldn't be nullish. foo");
29
30 reportCompare(0, 0);