MCPcopy Create free account
hub / github.com/angular/angular / checkMatch

Function checkMatch

packages/compiler-cli/preprocessor/test/utils.ts:596–610  ·  view source on GitHub ↗
(actual: string, expected: string)

Source from the content-addressed store, hash-verified

594}
595
596export function checkMatch(actual: string, expected: string): boolean {
597 if (!expected.includes('…')) {
598 return normalizeWhitespace(actual) === normalizeWhitespace(expected);
599 }
600
601 const normalizedActual = normalizeWhitespace(actual);
602 const normalizedExpected = normalizeWhitespace(expected);
603
604 const parts = normalizedExpected.split('…');
605 const escapedParts = parts.map((part) => escapeRegExp(part).replace(/\s+/g, '\\s*'));
606 const regexStr = '^\\s*' + escapedParts.join('[\\s\\S]*?') + '\\s*$';
607 const regex = new RegExp(regexStr);
608
609 return regex.test(normalizedActual);
610}
611
612/**
613 * Compare actual outputs with expected outputs

Callers 1

compareOutputsFunction · 0.85

Calls 6

normalizeWhitespaceFunction · 0.85
mapMethod · 0.80
escapeRegExpFunction · 0.70
joinMethod · 0.65
replaceMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected