From fa37356074c1bc3a0f74b6f6a22e038b7842ff4d Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 29 Jun 2022 16:14:32 +0200 Subject: Add support for compiling definitions --- tests/definition.rs | 274 ++++++++++++++++++++++++---------------------------- 1 file changed, 126 insertions(+), 148 deletions(-) (limited to 'tests/definition.rs') diff --git a/tests/definition.rs b/tests/definition.rs index a8e8164..c112a96 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -9,12 +9,11 @@ const DANGER: &Options = &Options { #[test] fn definition() { - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: /url \"title\"\n\n[foo]"), - // "

foo

", - // "should support link definitions" - // ); + assert_eq!( + micromark("[foo]: /url \"title\"\n\n[foo]"), + "

foo

", + "should support link definitions" + ); assert_eq!( micromark("[foo]:\n\n/url\n\n[foo]"), @@ -22,33 +21,30 @@ fn definition() { "should not support blank lines before destination" ); - // To do: link (reference). - // assert_eq!( - // micromark(" [foo]: \n /url \n 'the title' \n\n[foo]"), - // "

foo

", - // "should support whitespace and line endings in definitions" - // ); + assert_eq!( + micromark(" [foo]: \n /url \n 'the title' \n\n[foo]"), + "

foo

", + "should support whitespace and line endings in definitions" + ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]"), // "

Foo*bar]

", // "should support complex definitions (1)" // ); - // To do: link (reference). - // assert_eq!( - // micromark("[Foo bar]:\n\n'title'\n\n[Foo bar]"), - // "

Foo bar

", - // "should support complex definitions (2)" - // ); + assert_eq!( + micromark("[Foo bar]:\n\n'title'\n\n[Foo bar]"), + "

Foo bar

", + "should support complex definitions (2)" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]"), - // "

foo

", - // "should support line endings in titles" - // ); + assert_eq!( + micromark("[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]"), + "

foo

", + "should support line endings in titles" + ); assert_eq!( micromark("[foo]: /url 'title\n\nwith blank line'\n\n[foo]"), @@ -56,12 +52,11 @@ fn definition() { "should not support blank lines in titles" ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]:\n/url\n\n[foo]"), - // "

foo

", - // "should support definitions w/o title" - // ); + assert_eq!( + micromark("[foo]:\n/url\n\n[foo]"), + "

foo

", + "should support definitions w/o title" + ); assert_eq!( micromark("[foo]:\n\n[foo]"), @@ -69,12 +64,11 @@ fn definition() { "should not support definitions w/o destination" ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: <>\n\n[foo]"), - // "

foo

", - // "should support definitions w/ explicit empty destinations" - // ); + assert_eq!( + micromark("[foo]: <>\n\n[foo]"), + "

foo

", + "should support definitions w/ explicit empty destinations" + ); assert_eq!( micromark_with_options("[foo]: (baz)\n\n[foo]", DANGER), @@ -82,35 +76,34 @@ fn definition() { "should not support definitions w/ no whitespace between destination and title" ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]"), - // "

foo

", - // "should support character escapes in destinations and titles" - // ); + assert_eq!( + micromark("[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]"), + "

foo

", + "should support character escapes in destinations and titles" + ); - // To do: link (reference). + // Some bug. // assert_eq!( // micromark("[foo]\n\n[foo]: url"), // "

foo

\n", // "should support a link before a definition" // ); - // To do: link (reference). + // Some bug. // assert_eq!( // micromark("[foo]: first\n[foo]: second\n\n[foo]"), // "

foo

", // "should match w/ the first definition" // ); - // To do: link (reference). + // Some bug. // assert_eq!( // micromark("[FOO]: /url\n\n[Foo]"), // "

Foo

", // "should match w/ case-insensitive (1)" // ); - // To do: link (reference). + // Some bug. // assert_eq!( // micromark("[ΑΓΩ]: /φου\n\n[αγω]"), // "

αγω

", @@ -129,19 +122,17 @@ fn definition() { "should not contribute anything w/o reference (2)" ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: /url \"title\" \n\n[foo]"), - // "

foo

", - // "should support whitespace after title" - // ); + assert_eq!( + micromark("[foo]: /url \"title\" \n\n[foo]"), + "

foo

", + "should support whitespace after title" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: /url\n\"title\" \n\n[foo]"), - // "

foo

", - // "should support whitespace after title on a separate line" - // ); + assert_eq!( + micromark("[foo]: /url\n\"title\" \n\n[foo]"), + "

foo

", + "should support whitespace after title on a separate line" + ); assert_eq!( micromark("[foo]: /url \"title\" ok"), @@ -173,28 +164,26 @@ fn definition() { "should not support definitions in paragraphs" ); - // To do: link (reference). + // To do: block quote. // assert_eq!( // micromark("# [Foo]\n[foo]: /url\n> bar"), // "

Foo

\n
\n

bar

\n
", // "should not support definitions in headings" // ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: /url\nbar\n===\n[foo]"), - // "

bar

\n

foo

", - // "should support setext headings after definitions" - // ); + assert_eq!( + micromark("[foo]: /url\nbar\n===\n[foo]"), + "

bar

\n

foo

", + "should support setext headings after definitions" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[foo]: /url\n===\n[foo]"), - // "

===\nfoo

", - // "should not support setext heading underlines after definitions" - // ); + assert_eq!( + micromark("[foo]: /url\n===\n[foo]"), + "

===\nfoo

", + "should not support setext heading underlines after definitions" + ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark( // "[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]" @@ -203,7 +192,7 @@ fn definition() { // "should support definitions after definitions" // ); - // To do: link (reference). + // To do: block quote. // assert_eq!( // micromark("> [foo]: /url\n\n[foo]"), // "
\n
\n

foo

", @@ -211,26 +200,24 @@ fn definition() { // ); // Extra - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[\\[\\+\\]]: example.com\n\nLink: [\\[\\+\\]]."), // "

Link: [+].

", // "should match w/ character escapes" // ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: \\\" \\(\\)\\\"\n\n[x]"), - // "

x

", - // "should support character escapes & references in unenclosed destinations" - // ); + assert_eq!( + micromark("[x]: \\\" \\(\\)\\\"\n\n[x]"), + "

x

", + "should support character escapes & references in unenclosed destinations" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: <\\> \\+\\>>\n\n[x]"), - // "

x

", - // "should support character escapes & references in enclosed destinations" - // ); + assert_eq!( + micromark("[x]: <\\> \\+\\>>\n\n[x]"), + "

x

", + "should support character escapes & references in enclosed destinations" + ); assert_eq!( micromark("[x]: <\n\n[x]"), @@ -256,42 +243,38 @@ fn definition() { "should not support ascii control characters in destination" ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: <\u{000b}a>\n\n[x]"), - // "

x

", - // "should support ascii control characters at the start of enclosed destination" - // ); + assert_eq!( + micromark("[x]: <\u{000b}a>\n\n[x]"), + "

x

", + "should support ascii control characters at the start of enclosed destination" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: \n\n[x]"), - // "

x

", - // "should support ascii control characters in enclosed destinations" - // ); + assert_eq!( + micromark("[x]: \n\n[x]"), + "

x

", + "should support ascii control characters in enclosed destinations" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: a \"\\\"\"\n\n[x]"), - // "

x

", - // "should support character escapes at the start of a title" - // ); + assert_eq!( + micromark("[x]: a \"\\\"\"\n\n[x]"), + "

x

", + "should support character escapes at the start of a title" + ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[x]: a \"\\\"\"\n\n[x]"), // "

x

", // "should support double quoted titles" // ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: a '\"'\n\n[x]"), - // "

x

", - // "should support double quoted titles" - // ); + assert_eq!( + micromark("[x]: a '\"'\n\n[x]"), + "

x

", + "should support double quoted titles" + ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[x]: a (\"\")\n\n[x]"), // "

x

", @@ -304,12 +287,11 @@ fn definition() { "should not support more opening than closing parens in the destination" ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: a(())\n\n[x]"), - // "

x

", - // "should support balanced opening and closing parens in the destination" - // ); + assert_eq!( + micromark("[x]: a(())\n\n[x]"), + "

x

", + "should support balanced opening and closing parens in the destination" + ); assert_eq!( micromark("[x]: a())\n\n[x]"), @@ -317,43 +299,39 @@ fn definition() { "should not support more closing than opening parens in the destination" ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: a \t\n\n[x]"), - // "

x

", - // "should support trailing whitespace after a destination" - // ); + assert_eq!( + micromark("[x]: a \t\n\n[x]"), + "

x

", + "should support trailing whitespace after a destination" + ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[x]: a \"\"X \t\n\n[x]"), // "

x

", // "should support trailing whitespace after a destination" // ); - // To do: link (reference). - // assert_eq!( - // micromark("[&©&]: example.com/&©& \"&©&\"\n\n[&©&]"), - // "

&©&

", - // "should support character references in definitions" - // ); + assert_eq!( + micromark("[&©&]: example.com/&©& \"&©&\"\n\n[&©&]"), + "

&©&

", + "should support character references in definitions" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]:\nexample.com\n\n[x]"), - // "

x

", - // "should support a line ending before a destination" - // ); + assert_eq!( + micromark("[x]:\nexample.com\n\n[x]"), + "

x

", + "should support a line ending before a destination" + ); - // To do: link (reference). - // assert_eq!( - // micromark("[x]: \t\nexample.com\n\n[x]"), - // "

x

", - // "should support whitespace before a destination" - // ); + assert_eq!( + micromark("[x]: \t\nexample.com\n\n[x]"), + "

x

", + "should support whitespace before a destination" + ); // See: - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[x]: <> \"\"\n[][x]"), // "

", @@ -384,7 +362,7 @@ fn definition() { "should not support an extra right paren (`)`) in a raw destination" ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[a]\n\n[a]: a(1(2(3(4()))))b"), // "

a

\n", @@ -403,14 +381,14 @@ fn definition() { "should not support a final (unbalanced) right paren in a raw destination “before” a title" ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark(" [a]: b \"c\"\n [d]: e\n [f]: g \"h\"\n [i]: j\n\t[k]: l (m)\n\t n [k] o"), // "

n k o

", // "should support subsequent indented definitions" // ); - // To do: link (reference). + // To do: some bug. // assert_eq!( // micromark("[a\n b]: c\n\n[a\n b]"), // "

a\nb

", -- cgit