MCPcopy Create free account
hub / github.com/continuedev/continue / processTestCase

Function processTestCase

core/autocomplete/util/completionTestUtils.ts:52–94  ·  view source on GitHub ↗
({
  original,
  completion,
  appliedCompletion = null,
  cursorMarker = "|cur|",
  tillMarker = "|till|",
}: CompletionTestCase)

Source from the content-addressed store, hash-verified

50 *
51 */
52export function processTestCase({
53 original,
54 completion,
55 appliedCompletion = null,
56 cursorMarker = "|cur|",
57 tillMarker = "|till|",
58}: CompletionTestCase): ProcessedTestCase {
59 // Validate cursor marker
60 if (!original.includes(cursorMarker)) {
61 throw new Error("Cursor marker not found in original text");
62 }
63
64 const cursorPos = original.indexOf(cursorMarker);
65 original = original.replace(cursorMarker, "");
66
67 let tillPos = original.indexOf(tillMarker);
68 if (tillPos < 0) {
69 tillPos = cursorPos;
70 } else {
71 original = original.replace(tillMarker, "");
72 }
73
74 // Calculate currentText based on what's between cursor and till marker
75 const currentText = original.substring(cursorPos);
76
77 return {
78 input: {
79 lastLineOfCompletionText: completion,
80 currentText,
81 cursorPosition: cursorPos,
82 },
83 expectedResult: {
84 completionText: appliedCompletion || completion,
85 range:
86 cursorPos === tillPos
87 ? undefined
88 : {
89 start: cursorPos,
90 end: tillPos,
91 },
92 },
93 };
94}

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected