Skip to content

Commit 5b167bf

Browse files
update rustdoc unit tests
1 parent a6d26eb commit 5b167bf

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

src/librustdoc/html/markdown.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ mod tests {
10501050
use super::{ErrorCodes, LangString, Markdown, MarkdownHtml, IdMap};
10511051
use super::plain_summary_line;
10521052
use std::cell::RefCell;
1053-
use syntax::edition::Edition;
1053+
use syntax::edition::{Edition, DEFAULT_EDITION};
10541054

10551055
#[test]
10561056
fn test_lang_string_parse() {
@@ -1102,7 +1102,8 @@ mod tests {
11021102
fn test_header() {
11031103
fn t(input: &str, expect: &str) {
11041104
let mut map = IdMap::new();
1105-
let output = Markdown(input, &[], RefCell::new(&mut map), ErrorCodes::Yes).to_string();
1105+
let output = Markdown(input, &[], RefCell::new(&mut map),
1106+
ErrorCodes::Yes, DEFAULT_EDITION).to_string();
11061107
assert_eq!(output, expect, "original: {}", input);
11071108
}
11081109

@@ -1124,7 +1125,8 @@ mod tests {
11241125
fn test_header_ids_multiple_blocks() {
11251126
let mut map = IdMap::new();
11261127
fn t(map: &mut IdMap, input: &str, expect: &str) {
1127-
let output = Markdown(input, &[], RefCell::new(map), ErrorCodes::Yes).to_string();
1128+
let output = Markdown(input, &[], RefCell::new(map),
1129+
ErrorCodes::Yes, DEFAULT_EDITION).to_string();
11281130
assert_eq!(output, expect, "original: {}", input);
11291131
}
11301132

@@ -1161,7 +1163,8 @@ mod tests {
11611163
fn test_markdown_html_escape() {
11621164
fn t(input: &str, expect: &str) {
11631165
let mut idmap = IdMap::new();
1164-
let output = MarkdownHtml(input, RefCell::new(&mut idmap), ErrorCodes::Yes).to_string();
1166+
let output = MarkdownHtml(input, RefCell::new(&mut idmap),
1167+
ErrorCodes::Yes, DEFAULT_EDITION).to_string();
11651168
assert_eq!(output, expect, "original: {}", input);
11661169
}
11671170

src/librustdoc/test.rs

+18-17
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
884884
#[cfg(test)]
885885
mod tests {
886886
use super::{TestOptions, make_test};
887+
use syntax::edition::DEFAULT_EDITION;
887888

888889
#[test]
889890
fn make_test_basic() {
@@ -896,7 +897,7 @@ mod tests {
896897
fn main() {
897898
assert_eq!(2+2, 4);
898899
}".to_string();
899-
let output = make_test(input, None, false, &opts);
900+
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
900901
assert_eq!(output, (expected, 2));
901902
}
902903

@@ -912,7 +913,7 @@ assert_eq!(2+2, 4);
912913
fn main() {
913914
assert_eq!(2+2, 4);
914915
}".to_string();
915-
let output = make_test(input, Some("asdf"), false, &opts);
916+
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
916917
assert_eq!(output, (expected, 2));
917918
}
918919

@@ -931,7 +932,7 @@ fn main() {
931932
use asdf::qwop;
932933
assert_eq!(2+2, 4);
933934
}".to_string();
934-
let output = make_test(input, Some("asdf"), false, &opts);
935+
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
935936
assert_eq!(output, (expected, 3));
936937
}
937938

@@ -953,7 +954,7 @@ fn main() {
953954
use asdf::qwop;
954955
assert_eq!(2+2, 4);
955956
}".to_string();
956-
let output = make_test(input, Some("asdf"), false, &opts);
957+
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
957958
assert_eq!(output, (expected, 2));
958959
}
959960

@@ -972,7 +973,7 @@ fn main() {
972973
use std::*;
973974
assert_eq!(2+2, 4);
974975
}".to_string();
975-
let output = make_test(input, Some("std"), false, &opts);
976+
let output = make_test(input, Some("std"), false, &opts, DEFAULT_EDITION);
976977
assert_eq!(output, (expected, 2));
977978
}
978979

@@ -992,7 +993,7 @@ fn main() {
992993
use asdf::qwop;
993994
assert_eq!(2+2, 4);
994995
}".to_string();
995-
let output = make_test(input, Some("asdf"), false, &opts);
996+
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
996997
assert_eq!(output, (expected, 2));
997998
}
998999

@@ -1010,7 +1011,7 @@ fn main() {
10101011
use asdf::qwop;
10111012
assert_eq!(2+2, 4);
10121013
}".to_string();
1013-
let output = make_test(input, Some("asdf"), false, &opts);
1014+
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
10141015
assert_eq!(output, (expected, 2));
10151016
}
10161017

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

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

@@ -1061,7 +1062,7 @@ assert_eq!(2+2, 4);";
10611062
fn main() {
10621063
assert_eq!(2+2, 4);
10631064
}".to_string();
1064-
let output = make_test(input, None, false, &opts);
1065+
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
10651066
assert_eq!(output, (expected, 2));
10661067
}
10671068

@@ -1078,7 +1079,7 @@ assert_eq!(2+2, 4);
10781079
fn main() {
10791080
assert_eq!(2+2, 4);
10801081
}".to_string();
1081-
let output = make_test(input, None, false, &opts);
1082+
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
10821083
assert_eq!(output, (expected, 1));
10831084
}
10841085

@@ -1095,7 +1096,7 @@ assert_eq!(2+2, 4);";
10951096
fn main() {
10961097
assert_eq!(2+2, 4);
10971098
}".to_string();
1098-
let output = make_test(input, None, false, &opts);
1099+
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
10991100
assert_eq!(output, (expected, 2));
11001101
}
11011102

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

@@ -1125,7 +1126,7 @@ assert_eq!(2+2, 4);".to_string();
11251126
"fn main() {
11261127
assert_eq!(2+2, 4);
11271128
}".to_string();
1128-
let output = make_test(input, None, false, &opts);
1129+
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
11291130
assert_eq!(output, (expected, 1));
11301131
}
11311132

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

1147-
let output = make_test(input, None, false, &opts);
1148+
let output = make_test(input, None, false, &opts, DEFAULT_EDITION);
11481149
assert_eq!(output, (expected, 2));
11491150

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

1162-
let output = make_test(input, Some("asdf"), false, &opts);
1163+
let output = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION);
11631164
assert_eq!(output, (expected, 3));
11641165
}
11651166

@@ -1178,7 +1179,7 @@ test_wrapper! {
11781179
fn main() {}
11791180
}".to_string();
11801181

1181-
let output = make_test(input, Some("my_crate"), false, &opts);
1182+
let output = make_test(input, Some("my_crate"), false, &opts, DEFAULT_EDITION);
11821183
assert_eq!(output, (expected, 1));
11831184
}
11841185
}

0 commit comments

Comments
 (0)