Skip to content

Commit 00b695b

Browse files
committed
Format WHILE .. LOOP
1 parent 40a2ef2 commit 00b695b

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/syntax/procedural_language.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ export const proceduralLanguageMap: Partial<CstToDocMap<AllProceduralNodes>> = {
141141
hardline,
142142
print.spaced("endWhileKw"),
143143
]),
144+
while_loop_stmt: (print) =>
145+
group(print.spaced(["whileKw", "condition", "loop"])),
144146
// FOR .. IN
145147
for_stmt: (print) =>
146148
group([

test/proc/loops.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import dedent from "dedent-js";
2-
import { testBigquery } from "../test_utils";
2+
import { testBigquery, testPlpgsql } from "../test_utils";
33

44
describe("loops", () => {
55
it(`formats LOOP`, async () => {
@@ -26,6 +26,14 @@ describe("loops", () => {
2626
`);
2727
});
2828

29+
it(`formats WHILE .. LOOP .. END LOOP`, async () => {
30+
await testPlpgsql(dedent`
31+
WHILE x < 10 LOOP
32+
x = x + 1;
33+
END LOOP
34+
`);
35+
});
36+
2937
it(`formats FOR .. IN`, async () => {
3038
await testBigquery(dedent`
3139
FOR record IN (SELECT * FROM tbl) DO

0 commit comments

Comments
 (0)