Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
mscolnick committed Jan 6, 2025
1 parent 97648b5 commit b69c92c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frontend/src/core/errors/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ describe("wrapInFunction", () => {
const input = "1 + 2";
const expected = `def _():
return 1 + 2
_()`;
expect(wrapInFunction(input)).toBe(expected);
});
Expand All @@ -17,6 +19,8 @@ _()`;
const expected = `def _():
return (1 +
2)
_()`;
expect(wrapInFunction(input)).toBe(expected);
});
Expand All @@ -31,6 +35,8 @@ _()`;
bar(1, 2),
baz(3, 4)
)
_()`;
expect(wrapInFunction(input)).toBe(expected);
});
Expand All @@ -44,6 +50,8 @@ _()`;
x = 1
y = 2
return
_()`;
expect(wrapInFunction(input)).toBe(expected);
});
Expand All @@ -62,6 +70,8 @@ y = "bar"
x="x",
y="y",
))
_()`;
expect(wrapInFunction(input)).toBe(expected);
});
Expand All @@ -75,6 +85,8 @@ y = 2`;
y = 2
return
_()`;
expect(wrapInFunction(input)).toBe(expected);
});
Expand All @@ -88,6 +100,8 @@ _()`;
x = 1
y = 2
return
_()`;
expect(wrapInFunction(input)).toBe(expected);
});
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/core/errors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export function wrapInFunction(code: string) {
"def _():",
...indentLines(lines, indentation),
`${indentation}return`,
"",
"",
"_()",
].join("\n");
}
Expand All @@ -42,6 +44,8 @@ export function wrapInFunction(code: string) {
...indentLines(linesBeforeLastStmt, indentation),
`${indentation}return ${linesRest[0]}`,
...indentLines(linesRest.slice(1), indentation),
"",
"",
"_()",
].join("\n");
}
Expand Down

0 comments on commit b69c92c

Please sign in to comment.