diff --git a/src/notcl.test.ts b/src/notcl.test.ts index 4c63eca..eeee40b 100644 --- a/src/notcl.test.ts +++ b/src/notcl.test.ts @@ -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