Skip to content

Commit

Permalink
update rustdoc unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
QuietMisdreavus committed May 6, 2019
1 parent a6d26eb commit 5b167bf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
11 changes: 7 additions & 4 deletions src/librustdoc/html/markdown.rs
Expand Up @@ -1050,7 +1050,7 @@ mod tests {
use super::{ErrorCodes, LangString, Markdown, MarkdownHtml, IdMap};
use super::plain_summary_line;
use std::cell::RefCell;
use syntax::edition::Edition;
use syntax::edition::{Edition, DEFAULT_EDITION};

#[test]
fn test_lang_string_parse() {
Expand Down Expand Up @@ -1102,7 +1102,8 @@ mod tests {
fn test_header() {
fn t(input: &str, expect: &str) {
let mut map = IdMap::new();
let output = Markdown(input, &[], RefCell::new(&mut map), ErrorCodes::Yes).to_string();
let output = Markdown(input, &[], RefCell::new(&mut map),
ErrorCodes::Yes, DEFAULT_EDITION).to_string();
assert_eq!(output, expect, "original: {}", input);
}

Expand All @@ -1124,7 +1125,8 @@ mod tests {
fn test_header_ids_multiple_blocks() {
let mut map = IdMap::new();
fn t(map: &mut IdMap, input: &str, expect: &str) {
let output = Markdown(input, &[], RefCell::new(map), ErrorCodes::Yes).to_string();
let output = Markdown(input, &[], RefCell::new(map),
ErrorCodes::Yes, DEFAULT_EDITION).to_string();
assert_eq!(output, expect, "original: {}", input);
}

Expand Down Expand Up @@ -1161,7 +1163,8 @@ mod tests {
fn test_markdown_html_escape() {
fn t(input: &str, expect: &str) {
let mut idmap = IdMap::new();
let output = MarkdownHtml(input, RefCell::new(&mut idmap), ErrorCodes::Yes).to_string();
let output = MarkdownHtml(input, RefCell::new(&mut idmap),
ErrorCodes::Yes, DEFAULT_EDITION).to_string();
assert_eq!(output, expect, "original: {}", input);
}

Expand Down
35 changes: 18 additions & 17 deletions src/librustdoc/test.rs
Expand Up @@ -884,6 +884,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
#[cfg(test)]
mod tests {
use super::{TestOptions, make_test};
use syntax::edition::DEFAULT_EDITION;

#[test]
fn make_test_basic() {
Expand All @@ -896,7 +897,7 @@ mod tests {
fn main() {
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -912,7 +913,7 @@ assert_eq!(2+2, 4);
fn main() {
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -931,7 +932,7 @@ fn main() {
use asdf::qwop;
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 3));
}

Expand All @@ -953,7 +954,7 @@ fn main() {
use asdf::qwop;
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -972,7 +973,7 @@ fn main() {
use std::*;
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("std"), false, &opts);
let output = make_test(input, Some("std"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -992,7 +993,7 @@ fn main() {
use asdf::qwop;
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -1010,7 +1011,7 @@ fn main() {
use asdf::qwop;
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -1030,7 +1031,7 @@ fn main() {
use asdf::qwop;
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 3));

// Adding more will also bump the returned line offset.
Expand All @@ -1043,7 +1044,7 @@ fn main() {
use asdf::qwop;
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 4));
}

Expand All @@ -1061,7 +1062,7 @@ assert_eq!(2+2, 4);";
fn main() {
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -1078,7 +1079,7 @@ assert_eq!(2+2, 4);
fn main() {
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 1));
}

Expand All @@ -1095,7 +1096,7 @@ assert_eq!(2+2, 4);";
fn main() {
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));
}

Expand All @@ -1110,7 +1111,7 @@ assert_eq!(2+2, 4);";
"#![allow(unused)]
//Ceci n'est pas une `fn main`
assert_eq!(2+2, 4);".to_string();
let output = make_test(input, None, true, &opts);
let output = make_test(input, None, true, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 1));
}

Expand All @@ -1125,7 +1126,7 @@ assert_eq!(2+2, 4);".to_string();
"fn main() {
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 1));
}

Expand All @@ -1144,7 +1145,7 @@ fn main() {
assert_eq!(2+2, 4);
}".to_string();

let output = make_test(input, None, false, &opts);
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 2));

let input =
Expand All @@ -1159,7 +1160,7 @@ fn main() {
assert_eq!(asdf::foo, 4);
}".to_string();

let output = make_test(input, Some("asdf"), false, &opts);
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 3));
}

Expand All @@ -1178,7 +1179,7 @@ test_wrapper! {
fn main() {}
}".to_string();

let output = make_test(input, Some("my_crate"), false, &opts);
let output = make_test(input, Some("my_crate"), false, &opts, DEFAULT_EDITION);
assert_eq!(output, (expected, 1));
}
}

0 comments on commit 5b167bf

Please sign in to comment.