MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / matchArray

Function matchArray

test/shared/helper.ts:59–72  ·  view source on GitHub ↗
(
    actual: A[], expected: E[], comparator: (actual: A, expected: E) => true | string)

Source from the content-addressed store, hash-verified

57}
58
59export function matchArray<A, E>(
60 actual: A[], expected: E[], comparator: (actual: A, expected: E) => true | string): true|string {
61 if (actual.length !== expected.length) {
62 return `Expected [${actual.map(x => `"${x}"`).join(', ')}] to have length ${expected.length}`;
63 }
64
65 for (let i = 0; i < expected.length; ++i) {
66 const result = comparator(actual[i], expected[i]);
67 if (result !== true) {
68 return `Mismatch in row ${i}: ${result}`;
69 }
70 }
71 return true;
72}
73
74export function assertOk<Args extends unknown[]>(check: (...args: Args) => true | string) {
75 return (...args: Args) => {

Callers 2

matchTableFunction · 0.85
matchStringArrayFunction · 0.85

Calls 3

comparatorFunction · 0.50
joinMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected