about summary refs log tree commit diff
path: root/src/librustdoc/html/markdown
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-24 17:38:22 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-24 17:38:22 -0500
commit6891388e661c2bbf965a330ff73bf8c08a7dbf7d (patch)
treeff2f518c1dfdb558a162c73b3ee3f2a0b44d5adc /src/librustdoc/html/markdown
parent48291a9dda821a81957b44034572c0ec62728f35 (diff)
downloadrust-6891388e661c2bbf965a330ff73bf8c08a7dbf7d.tar.gz
rust-6891388e661c2bbf965a330ff73bf8c08a7dbf7d.zip
x.py fmt after previous deignore
Diffstat (limited to 'src/librustdoc/html/markdown')
-rw-r--r--src/librustdoc/html/markdown/tests.rs233
1 files changed, 162 insertions, 71 deletions
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index 5d6811a29a3..862c6c56c78 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -1,16 +1,42 @@
-use super::{ErrorCodes, LangString, Markdown, MarkdownHtml, IdMap, Ignore};
 use super::plain_summary_line;
+use super::{ErrorCodes, IdMap, Ignore, LangString, Markdown, MarkdownHtml};
 use std::cell::RefCell;
 use syntax::edition::{Edition, DEFAULT_EDITION};
 
 #[test]
 fn test_unique_id() {
-    let input = ["foo", "examples", "examples", "method.into_iter","examples",
-                 "method.into_iter", "foo", "main", "search", "methods",
-                 "examples", "method.into_iter", "assoc_type.Item", "assoc_type.Item"];
-    let expected = ["foo", "examples", "examples-1", "method.into_iter", "examples-2",
-                    "method.into_iter-1", "foo-1", "main", "search", "methods",
-                    "examples-3", "method.into_iter-2", "assoc_type.Item", "assoc_type.Item-1"];
+    let input = [
+        "foo",
+        "examples",
+        "examples",
+        "method.into_iter",
+        "examples",
+        "method.into_iter",
+        "foo",
+        "main",
+        "search",
+        "methods",
+        "examples",
+        "method.into_iter",
+        "assoc_type.Item",
+        "assoc_type.Item",
+    ];
+    let expected = [
+        "foo",
+        "examples",
+        "examples-1",
+        "method.into_iter",
+        "examples-2",
+        "method.into_iter-1",
+        "foo-1",
+        "main",
+        "search",
+        "methods",
+        "examples-3",
+        "method.into_iter-2",
+        "assoc_type.Item",
+        "assoc_type.Item-1",
+    ];
 
     let map = RefCell::new(IdMap::new());
     let test = || {
@@ -25,96 +51,161 @@ fn test_unique_id() {
 
 #[test]
 fn test_lang_string_parse() {
-    fn t(s: &str,
-        should_panic: bool, no_run: bool, ignore: Ignore, rust: bool, test_harness: bool,
-        compile_fail: bool, allow_fail: bool, error_codes: Vec<String>,
-        edition: Option<Edition>) {
-        assert_eq!(LangString::parse(s, ErrorCodes::Yes, true), LangString {
-            should_panic,
-            no_run,
-            ignore,
-            rust,
-            test_harness,
-            compile_fail,
-            error_codes,
-            original: s.to_owned(),
-            allow_fail,
-            edition,
-        })
+    fn t(
+        s: &str,
+        should_panic: bool,
+        no_run: bool,
+        ignore: Ignore,
+        rust: bool,
+        test_harness: bool,
+        compile_fail: bool,
+        allow_fail: bool,
+        error_codes: Vec<String>,
+        edition: Option<Edition>,
+    ) {
+        assert_eq!(
+            LangString::parse(s, ErrorCodes::Yes, true),
+            LangString {
+                should_panic,
+                no_run,
+                ignore,
+                rust,
+                test_harness,
+                compile_fail,
+                error_codes,
+                original: s.to_owned(),
+                allow_fail,
+                edition,
+            }
+        )
     }
-    let ignore_foo = Ignore::Some(vec!("foo".to_string()));
+    let ignore_foo = Ignore::Some(vec!["foo".to_string()]);
 
     fn v() -> Vec<String> {
         Vec::new()
     }
 
-    // ignore-tidy-linelength
     // marker                | should_panic | no_run | ignore | rust | test_harness
     //                       | compile_fail | allow_fail | error_codes | edition
-    t("",                      false,         false,   Ignore::None,   true,  false, false, false, v(), None);
-    t("rust",                  false,         false,   Ignore::None,   true,  false, false, false, v(), None);
-    t("sh",                    false,         false,   Ignore::None,   false, false, false, false, v(), None);
-    t("ignore",                false,         false,   Ignore::All,    true,  false, false, false, v(), None);
-    t("ignore-foo",            false,         false,   ignore_foo,     true,  false, false, false, v(), None);
-    t("should_panic",          true,          false,   Ignore::None,   true,  false, false, false, v(), None);
-    t("no_run",                false,         true,    Ignore::None,   true,  false, false, false, v(), None);
-    t("test_harness",          false,         false,   Ignore::None,   true,  true,  false, false, v(), None);
-    t("compile_fail",          false,         true,    Ignore::None,   true,  false, true,  false, v(), None);
-    t("allow_fail",            false,         false,   Ignore::None,   true,  false, false, true,  v(), None);
-    t("{.no_run .example}",    false,         true,    Ignore::None,   true,  false, false, false, v(), None);
-    t("{.sh .should_panic}",   true,          false,   Ignore::None,   false, false, false, false, v(), None);
-    t("{.example .rust}",      false,         false,   Ignore::None,   true,  false, false, false, v(), None);
-    t("{.test_harness .rust}", false,         false,   Ignore::None,   true,  true,  false, false, v(), None);
-    t("text, no_run",          false,         true,    Ignore::None,   false, false, false, false, v(), None);
-    t("text,no_run",           false,         true,    Ignore::None,   false, false, false, false, v(), None);
-    t("edition2015",           false,         false,   Ignore::None,   true,  false, false, false, v(), Some(Edition::Edition2015));
-    t("edition2018",           false,         false,   Ignore::None,   true,  false, false, false, v(), Some(Edition::Edition2018));
+    t("", false, false, Ignore::None, true, false, false, false, v(), None);
+    t("rust", false, false, Ignore::None, true, false, false, false, v(), None);
+    t("sh", false, false, Ignore::None, false, false, false, false, v(), None);
+    t("ignore", false, false, Ignore::All, true, false, false, false, v(), None);
+    t("ignore-foo", false, false, ignore_foo, true, false, false, false, v(), None);
+    t("should_panic", true, false, Ignore::None, true, false, false, false, v(), None);
+    t("no_run", false, true, Ignore::None, true, false, false, false, v(), None);
+    t("test_harness", false, false, Ignore::None, true, true, false, false, v(), None);
+    t("compile_fail", false, true, Ignore::None, true, false, true, false, v(), None);
+    t("allow_fail", false, false, Ignore::None, true, false, false, true, v(), None);
+    t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None);
+    t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None);
+    t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None);
+    t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None);
+    t("text, no_run", false, true, Ignore::None, false, false, false, false, v(), None);
+    t("text,no_run", false, true, Ignore::None, false, false, false, false, v(), None);
+    t(
+        "edition2015",
+        false,
+        false,
+        Ignore::None,
+        true,
+        false,
+        false,
+        false,
+        v(),
+        Some(Edition::Edition2015),
+    );
+    t(
+        "edition2018",
+        false,
+        false,
+        Ignore::None,
+        true,
+        false,
+        false,
+        false,
+        v(),
+        Some(Edition::Edition2018),
+    );
 }
 
 #[test]
 fn test_header() {
     fn t(input: &str, expect: &str) {
         let mut map = IdMap::new();
-        let output = Markdown(
-            input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
+        let output =
+            Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
         assert_eq!(output, expect, "original: {}", input);
     }
 
-    t("# Foo bar", "<h1 id=\"foo-bar\" class=\"section-header\">\
-      <a href=\"#foo-bar\">Foo bar</a></h1>");
-    t("## Foo-bar_baz qux", "<h2 id=\"foo-bar_baz-qux\" class=\"section-\
-      header\"><a href=\"#foo-bar_baz-qux\">Foo-bar_baz qux</a></h2>");
-    t("### **Foo** *bar* baz!?!& -_qux_-%",
-      "<h3 id=\"foo-bar-baz--qux-\" class=\"section-header\">\
+    t(
+        "# Foo bar",
+        "<h1 id=\"foo-bar\" class=\"section-header\">\
+      <a href=\"#foo-bar\">Foo bar</a></h1>",
+    );
+    t(
+        "## Foo-bar_baz qux",
+        "<h2 id=\"foo-bar_baz-qux\" class=\"section-\
+      header\"><a href=\"#foo-bar_baz-qux\">Foo-bar_baz qux</a></h2>",
+    );
+    t(
+        "### **Foo** *bar* baz!?!& -_qux_-%",
+        "<h3 id=\"foo-bar-baz--qux-\" class=\"section-header\">\
       <a href=\"#foo-bar-baz--qux-\"><strong>Foo</strong> \
-      <em>bar</em> baz!?!&amp; -<em>qux</em>-%</a></h3>");
-    t("#### **Foo?** & \\*bar?!*  _`baz`_ ❤ #qux",
-      "<h4 id=\"foo--bar--baz--qux\" class=\"section-header\">\
+      <em>bar</em> baz!?!&amp; -<em>qux</em>-%</a></h3>",
+    );
+    t(
+        "#### **Foo?** & \\*bar?!*  _`baz`_ ❤ #qux",
+        "<h4 id=\"foo--bar--baz--qux\" class=\"section-header\">\
       <a href=\"#foo--bar--baz--qux\"><strong>Foo?</strong> &amp; *bar?!*  \
-      <em><code>baz</code></em> ❤ #qux</a></h4>");
+      <em><code>baz</code></em> ❤ #qux</a></h4>",
+    );
 }
 
 #[test]
 fn test_header_ids_multiple_blocks() {
     let mut map = IdMap::new();
     fn t(map: &mut IdMap, input: &str, expect: &str) {
-        let output = Markdown(input, &[], map,
-                              ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
+        let output = Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
         assert_eq!(output, expect, "original: {}", input);
     }
 
-    t(&mut map, "# Example", "<h1 id=\"example\" class=\"section-header\">\
-        <a href=\"#example\">Example</a></h1>");
-    t(&mut map, "# Panics", "<h1 id=\"panics\" class=\"section-header\">\
-        <a href=\"#panics\">Panics</a></h1>");
-    t(&mut map, "# Example", "<h1 id=\"example-1\" class=\"section-header\">\
-        <a href=\"#example-1\">Example</a></h1>");
-    t(&mut map, "# Main", "<h1 id=\"main\" class=\"section-header\">\
-        <a href=\"#main\">Main</a></h1>");
-    t(&mut map, "# Example", "<h1 id=\"example-2\" class=\"section-header\">\
-        <a href=\"#example-2\">Example</a></h1>");
-    t(&mut map, "# Panics", "<h1 id=\"panics-1\" class=\"section-header\">\
-        <a href=\"#panics-1\">Panics</a></h1>");
+    t(
+        &mut map,
+        "# Example",
+        "<h1 id=\"example\" class=\"section-header\">\
+        <a href=\"#example\">Example</a></h1>",
+    );
+    t(
+        &mut map,
+        "# Panics",
+        "<h1 id=\"panics\" class=\"section-header\">\
+        <a href=\"#panics\">Panics</a></h1>",
+    );
+    t(
+        &mut map,
+        "# Example",
+        "<h1 id=\"example-1\" class=\"section-header\">\
+        <a href=\"#example-1\">Example</a></h1>",
+    );
+    t(
+        &mut map,
+        "# Main",
+        "<h1 id=\"main\" class=\"section-header\">\
+        <a href=\"#main\">Main</a></h1>",
+    );
+    t(
+        &mut map,
+        "# Example",
+        "<h1 id=\"example-2\" class=\"section-header\">\
+        <a href=\"#example-2\">Example</a></h1>",
+    );
+    t(
+        &mut map,
+        "# Panics",
+        "<h1 id=\"panics-1\" class=\"section-header\">\
+        <a href=\"#panics-1\">Panics</a></h1>",
+    );
 }
 
 #[test]
@@ -136,8 +227,8 @@ fn test_plain_summary_line() {
 fn test_markdown_html_escape() {
     fn t(input: &str, expect: &str) {
         let mut idmap = IdMap::new();
-        let output = MarkdownHtml(input, &mut idmap,
-                                  ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
+        let output =
+            MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
         assert_eq!(output, expect, "original: {}", input);
     }