Write brace tests
This commit is contained in:
parent
308f586dad
commit
2261d18d56
1 changed files with 54 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue