Write brace tests

This commit is contained in:
Tangent Wantwight 2023-08-10 21:51:23 -04:00
parent 308f586dad
commit 2261d18d56

View file

@ -88,7 +88,60 @@ b`)
).toEqual([true, []]));
});
// Enchanted Words
describe("enchanted words", () => {
// Enchanted Words
// simple words
// not braces
// not quotes
// not variables
// not commands
// not backslashes
// yes before folded newline
// no before folded newline that gives us backslashes
});
describe("interpolated words", () => {});
describe("brace words", () => {
it("can parse empty braces", () =>
expect(parse("{}")).toEqual([true, [[{ text: "" }]]]));
it("can parse braces with text", () =>
expect(parse("{a b c}")).toEqual([true, [[{ text: "a b c" }]]]));
it("can parse nested braces", () =>
expect(parse("{{}}")).toEqual([true, [[{ text: "{}" }]]]));
it("can parse nested braces with text", () =>
expect(parse("{a{b}c}")).toEqual([true, [[{ text: "a{b}c" }]]]));
it.failing("doesn't count suppressed braces for nesting", () =>
expect(parse(String.raw`{a\{b}`)).toEqual([true, [[{ text: "a\\{b" }]]])
);
it.failing("doesn't count suppressed braces for unnesting", () =>
expect(parse(String.raw`{a\}b}`)).toEqual([true, [[{ text: "a\\}b" }]]])
);
it("nests braces after suppressed backslashes", () =>
expect(parse(String.raw`{a\\{b}}`)).toEqual([
true,
[[{ text: "a\\\\{b}" }]],
]));
it("permits newlines in braces", () =>
expect(parse("{\n}")).toEqual([true, [[{ text: "\n" }]]]));
it("folds newlines in braces", () =>
expect(
parse(String.raw`{\
}`)
).toEqual([true, [[{ text: " " }]]]));
it("doesn't fold newlines in braces with escaped backslashes", () =>
expect(
parse(String.raw`{\\
}`)
).toEqual([true, [[{ text: "\\\\\n" }]]]));
it("folds newlines in braces with escaped backslashes", () =>
expect(
parse(String.raw`{\\\
}`)
).toEqual([true, [[{ text: "\\\\ " }]]]));
});
// Braces
// nesting