MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / expectSameShape

Function expectSameShape

__tests__/objcpp-cpp-items.test.ts:524–532  ·  view source on GitHub ↗

Each part is the file's length and breaks its lines where the file does.

(source: string)

Source from the content-addressed store, hash-verified

522
523 /** Each part is the file's length and breaks its lines where the file does. */
524 function expectSameShape(source: string): void {
525 const parts = splitObjcpp(source)!;
526 expect(parts).not.toBeNull();
527 const newlines = (text: string): number[] => [...text].flatMap((ch, k) => (ch === '\n' ? [k] : []));
528 for (const part of [parts.cpp, withoutObjcppItems(source, parts.items), parts.sends ?? source]) {
529 expect(part.length).toBe(source.length);
530 expect(newlines(part)).toEqual(newlines(source));
531 }
532 }
533
534 it('keeps every offset and every line of the file in each part', () => {
535 for (const source of [ISSUE, POOLED, MIXED, SYNTAX, CONSTANTS, BESIDE, CONDITIONAL]) expectSameShape(source);

Callers 1

Calls 3

splitObjcppFunction · 0.90
withoutObjcppItemsFunction · 0.90
newlinesFunction · 0.85

Tested by

no test coverage detected