diff --git a/src/parse.test.ts b/src/parse.test.ts index 4e3c500..ad5ecc4 100644 --- a/src/parse.test.ts +++ b/src/parse.test.ts @@ -112,6 +112,21 @@ describe("parse", () => { expect(result.commands[0]!.expected).toEqual(["$ hello"]) }) + test("multiple escaped dollar signs", () => { + const content = "$ printf '$ a\\n$ b\\n'\n\\$ a\n\\$ b\n" + const result = parse("test.shout", content) + expect(result.commands).toHaveLength(1) + expect(result.commands[0]!.expected).toEqual(["$ a", "$ b"]) + }) + + test("escaped dollar before first command is ignored", () => { + const content = "\\$ not a command\n$ echo hi\nhi\n" + const result = parse("test.shout", content) + // \$ before any command — no current command to attach to, so skipped + expect(result.commands).toHaveLength(1) + expect(result.commands[0]!.expected).toEqual(["hi"]) + }) + test("no directives returns empty array", () => { const result = parse("test.shout", "$ echo hi\nhi\n") expect(result.directives).toEqual([]) diff --git a/test/dollar-sign-output.shout b/test/dollar-sign-output.shout new file mode 100644 index 0000000..e41109c --- /dev/null +++ b/test/dollar-sign-output.shout @@ -0,0 +1,9 @@ +$ echo '$ hello world' +\$ hello world + +$ printf '$ line one\n$ line two\n' +\$ line one +\$ line two + +$ echo 'no dollar here' +no dollar here