Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 3898324

Browse files
committed
Use Racer enum for bool argument
1 parent fb80e67 commit 3898324

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/actions/hover.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,15 +2052,29 @@ pub mod test {
20522052
assert_eq!(expected, actual);
20532053
}
20542054

2055+
enum Racer {
2056+
Yes,
2057+
No,
2058+
}
2059+
2060+
impl Into<bool> for Racer {
2061+
fn into(self) -> bool {
2062+
match self {
2063+
Racer::Yes => true,
2064+
Racer::No => false,
2065+
}
2066+
}
2067+
}
2068+
20552069
// Common logic used in `test_tooltip_*` tests below
2056-
fn run_tooltip_tests(tests: &[Test], proj_dir: PathBuf, racer_completion: bool) -> Result<(), Box<dyn std::error::Error>> {
2070+
fn run_tooltip_tests(tests: &[Test], proj_dir: PathBuf, racer_completion: Racer) -> Result<(), Box<dyn std::error::Error>> {
20572071
let out = LineOutput::default();
20582072

20592073
let save_dir_guard = tempfile::tempdir().unwrap();
20602074
let save_dir = save_dir_guard.path().to_owned();
20612075
let load_dir = proj_dir.join("save_data");
20622076

2063-
let harness = TooltipTestHarness::new(proj_dir, &out, racer_completion);
2077+
let harness = TooltipTestHarness::new(proj_dir, &out, racer_completion.into());
20642078

20652079
out.reset();
20662080

@@ -2127,7 +2141,7 @@ pub mod test {
21272141
Test::new("test_tooltip_mod_use.rs", 13, 28),
21282142
];
21292143

2130-
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), false)
2144+
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), Racer::No)
21312145
}
21322146

21332147
#[test]
@@ -2142,7 +2156,7 @@ pub mod test {
21422156
Test::new("test_tooltip_mod_use_external.rs", 12, 12),
21432157
];
21442158

2145-
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), true)
2159+
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), Racer::Yes)
21462160
}
21472161

21482162
/// Note: This test is ignored as it doesn't work in the rust-lang/rust repo.
@@ -2169,7 +2183,7 @@ pub mod test {
21692183
Test::new("test_tooltip_std.rs", 25, 25),
21702184
];
21712185

2172-
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), false)
2186+
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), Racer::No)
21732187
}
21742188

21752189
/// Note: This test is ignored as it doesn't work in the rust-lang/rust repo.
@@ -2186,6 +2200,6 @@ pub mod test {
21862200
Test::new("test_tooltip_mod_use_external.rs", 15, 12),
21872201
];
21882202

2189-
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), true)
2203+
run_tooltip_tests(&tests, FIXTURES_DIR.join("hover"), Racer::Yes)
21902204
}
21912205
}

0 commit comments

Comments
 (0)