simplify some tests

This commit is contained in:
Aleksey Kladov 2019-10-10 14:51:35 +03:00
parent ce0d4a3b1d
commit 5140283277

View File

@ -80,18 +80,15 @@ fn module_resolution_works_for_non_standard_filenames() {
#[test]
fn module_resolution_works_for_raw_modules() {
let map = def_map_with_crate_graph(
let map = def_map(
"
//- /library.rs
//- /lib.rs
mod r#async;
use self::r#async::Bar;
//- /async.rs
pub struct Bar;
",
crate_graph! {
"library": ("/library.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -106,9 +103,9 @@ fn module_resolution_works_for_raw_modules() {
#[test]
fn module_resolution_decl_path() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /library.rs
//- /lib.rs
#[path = "bar/baz/foo.rs"]
mod foo;
use self::foo::Bar;
@ -116,9 +113,6 @@ fn module_resolution_decl_path() {
//- /bar/baz/foo.rs
pub struct Bar;
"###,
crate_graph! {
"library": ("/library.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -133,7 +127,7 @@ fn module_resolution_decl_path() {
#[test]
fn module_resolution_module_with_path_in_mod_rs() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo;
@ -147,9 +141,6 @@ fn module_resolution_module_with_path_in_mod_rs() {
//- /foo/baz.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -167,7 +158,7 @@ fn module_resolution_module_with_path_in_mod_rs() {
#[test]
fn module_resolution_module_with_path_non_crate_root() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo;
@ -181,9 +172,6 @@ fn module_resolution_module_with_path_non_crate_root() {
//- /baz.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -201,7 +189,7 @@ fn module_resolution_module_with_path_non_crate_root() {
#[test]
fn module_resolution_module_decl_path_super() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "bar/baz/module.rs"]
@ -211,9 +199,6 @@ fn module_resolution_module_decl_path_super() {
//- /bar/baz/module.rs
use super::Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -228,7 +213,7 @@ fn module_resolution_module_decl_path_super() {
#[test]
fn module_resolution_explicit_path_mod_rs() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "module/mod.rs"]
@ -237,9 +222,6 @@ fn module_resolution_explicit_path_mod_rs() {
//- /module/mod.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -253,7 +235,7 @@ fn module_resolution_explicit_path_mod_rs() {
#[test]
fn module_resolution_relative_path() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo;
@ -265,9 +247,6 @@ fn module_resolution_relative_path() {
//- /sub.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -284,7 +263,7 @@ fn module_resolution_relative_path() {
#[test]
fn module_resolution_relative_path_2() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo;
@ -296,9 +275,6 @@ fn module_resolution_relative_path_2() {
//- /sub.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -315,7 +291,7 @@ fn module_resolution_relative_path_2() {
#[test]
fn module_resolution_explicit_path_mod_rs_2() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "module/bar/mod.rs"]
@ -324,9 +300,6 @@ fn module_resolution_explicit_path_mod_rs_2() {
//- /module/bar/mod.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -340,7 +313,7 @@ fn module_resolution_explicit_path_mod_rs_2() {
#[test]
fn module_resolution_explicit_path_mod_rs_with_win_separator() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "module\bar\mod.rs"]
@ -349,9 +322,6 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() {
//- /module/bar/mod.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -365,7 +335,7 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() {
#[test]
fn module_resolution_decl_inside_inline_module_with_path_attribute() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "models"]
@ -376,9 +346,6 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() {
//- /models/bar.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -395,7 +362,7 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() {
#[test]
fn module_resolution_decl_inside_inline_module() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo {
@ -405,9 +372,6 @@ fn module_resolution_decl_inside_inline_module() {
//- /foo/bar.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -424,7 +388,7 @@ fn module_resolution_decl_inside_inline_module() {
#[test]
fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "models/db"]
@ -435,9 +399,6 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
//- /models/db/bar.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -454,7 +415,7 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
#[test]
fn module_resolution_decl_inside_inline_module_3() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "models/db"]
@ -466,9 +427,6 @@ fn module_resolution_decl_inside_inline_module_3() {
//- /models/db/users.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -485,7 +443,7 @@ fn module_resolution_decl_inside_inline_module_3() {
#[test]
fn module_resolution_decl_inside_inline_module_empty_path() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = ""]
@ -497,9 +455,6 @@ fn module_resolution_decl_inside_inline_module_empty_path() {
//- /users.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -516,7 +471,7 @@ fn module_resolution_decl_inside_inline_module_empty_path() {
#[test]
fn module_resolution_decl_empty_path() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = ""] // Should try to read `/` (a directory)
@ -525,9 +480,6 @@ fn module_resolution_decl_empty_path() {
//- /foo.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -537,7 +489,7 @@ fn module_resolution_decl_empty_path() {
#[test]
fn module_resolution_decl_inside_inline_module_relative_path() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path = "./models"]
@ -548,9 +500,6 @@ fn module_resolution_decl_inside_inline_module_relative_path() {
//- /models/bar.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -567,7 +516,7 @@ fn module_resolution_decl_inside_inline_module_relative_path() {
#[test]
fn module_resolution_decl_inside_inline_module_in_crate_root() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo {
@ -579,9 +528,6 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
//- /foo/baz.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -599,7 +545,7 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
#[test]
fn module_resolution_decl_inside_inline_module_in_mod_rs() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo;
@ -614,9 +560,6 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() {
//- /foo/bar/qwe.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -637,7 +580,7 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() {
#[test]
fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo;
@ -652,9 +595,6 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
//- /foo/bar/qwe.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -675,7 +615,7 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
#[test]
fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
mod foo;
@ -690,9 +630,6 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() {
//- /bar/baz.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"
@ -732,7 +669,7 @@ fn unresolved_module_diagnostics() {
#[test]
fn module_resolution_decl_inside_module_in_non_crate_root_2() {
let map = def_map_with_crate_graph(
let map = def_map(
r###"
//- /main.rs
#[path="module/m2.rs"]
@ -744,9 +681,6 @@ fn module_resolution_decl_inside_module_in_non_crate_root_2() {
//- /module/submod.rs
pub struct Baz;
"###,
crate_graph! {
"main": ("/main.rs", []),
},
);
assert_snapshot!(map, @r###"