MCPcopy
hub / github.com/greggman/twgl.js / assertArrayEqual

Function assertArrayEqual

test/assert.js:81–97  ·  view source on GitHub ↗
(actual, expected, msg = '')

Source from the content-addressed store, hash-verified

79}
80
81export function assertArrayEqual(actual, expected, msg = '') {
82 if (actual.length !== expected.length) {
83 throw new Error(`${formatMsg(msg)}expected: array.length ${expected.length} to equal actual.length: ${actual.length}`);
84 }
85 const errors = [];
86 for (let i = 0; i < actual.length; ++i) {
87 if (actual[i] !== expected[i]) {
88 errors.push(`${formatMsg(msg)}expected: expected[${i}] ${expected[i]} to equal actual[${i}]: ${actual[i]}`);
89 if (errors.length === 10) {
90 break;
91 }
92 }
93 }
94 if (errors.length > 0) {
95 throw new Error(errors.join('\n'));
96 }
97}
98
99export function assertThrowsWith(func, expectations, msg = '') {
100 let error = '';

Callers 3

checkColorFunction · 0.90
program-tests.jsFile · 0.90
assertEqualFunction · 0.85

Calls 2

formatMsgFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected