mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
test(yaml): add regexp type tests (#5862)
* initial commit * update * update
This commit is contained in:
parent
fab118b515
commit
0b59bfd465
@ -1086,3 +1086,47 @@ Deno.test("parse() handles string", () => {
|
|||||||
assertEquals(parse("!!str"), "");
|
assertEquals(parse("!!str"), "");
|
||||||
assertEquals(parse("!!str 2002-04-28"), "2002-04-28");
|
assertEquals(parse("!!str 2002-04-28"), "2002-04-28");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test({
|
||||||
|
name: "parse() handles regexp value with extended schema option",
|
||||||
|
fn() {
|
||||||
|
assertEquals(
|
||||||
|
parse("!<tag:yaml.org,2002:js/regexp> ^foo$\n", { schema: "extended" }),
|
||||||
|
/^foo$/,
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
parse("!<tag:yaml.org,2002:js/regexp> /^foo$/\n", { schema: "extended" }),
|
||||||
|
/^foo$/,
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
parse("!<tag:yaml.org,2002:js/regexp> /^foo$/g\n", {
|
||||||
|
schema: "extended",
|
||||||
|
}),
|
||||||
|
/^foo$/g,
|
||||||
|
);
|
||||||
|
assertThrows(
|
||||||
|
() =>
|
||||||
|
parse("!<tag:yaml.org,2002:js/regexp> /^foo$/gg\n", {
|
||||||
|
schema: "extended",
|
||||||
|
}),
|
||||||
|
SyntaxError,
|
||||||
|
"Cannot resolve a node",
|
||||||
|
);
|
||||||
|
assertThrows(
|
||||||
|
() =>
|
||||||
|
parse("!<tag:yaml.org,2002:js/regexp> \n", {
|
||||||
|
schema: "extended",
|
||||||
|
}),
|
||||||
|
SyntaxError,
|
||||||
|
"Cannot resolve a node",
|
||||||
|
);
|
||||||
|
assertThrows(
|
||||||
|
() =>
|
||||||
|
parse("!<tag:yaml.org,2002:js/regexp> /\n", {
|
||||||
|
schema: "extended",
|
||||||
|
}),
|
||||||
|
SyntaxError,
|
||||||
|
"Cannot resolve a node",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user