Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(yaml): test parsing of single quoted scalars #5356

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions yaml/parse_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,28 @@ Deno.test("parse() handles escaped strings in double quotes", () => {
);
});

Deno.test("parse() handles single quoted scalar", () => {
assertEquals(parse("'bar'"), "bar");
// escaped single quote
assertEquals(parse("'''bar'''"), "'bar'");
// line break in single quoted scalar
assertEquals(parse("'foo\nbar'"), "foo bar");

assertThrows(
// document end in single quoted scalar
() => parse("'bar\n"),
YamlError,
"unexpected end of the stream within a single quoted scalar at line 2, column 1:\n \n ^",
);

assertThrows(
// document separator appears in single quoted scalar
() => parse("'bar\n..."),
YamlError,
"unexpected end of the document within a single quoted scalar at line 2, column 1:\n ...\n ^",
);
});

Deno.test("parse() handles %YAML directive", () => {
assertEquals(
parse(`%YAML 1.2
Expand Down