Reduce merged doctest source code size

This commit is contained in:
Guillaume Gomez
2024-06-20 16:39:52 +02:00
parent d512438435
commit 1e1743a379
2 changed files with 41 additions and 25 deletions

View File

@@ -250,3 +250,37 @@ pub struct TestDescAndFn {
pub desc: TestDesc,
pub testfn: TestFn,
}
impl TestDescAndFn {
pub const fn new_doctest(
test_name: &'static str,
ignore: bool,
source_file: &'static str,
start_line: usize,
no_run: bool,
should_panic: bool,
testfn: TestFn,
) -> Self {
Self {
desc: TestDesc {
name: StaticTestName(test_name),
ignore,
ignore_message: None,
source_file,
start_line,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run,
should_panic: if should_panic {
options::ShouldPanic::Yes
} else {
options::ShouldPanic::No
},
test_type: TestType::DocTest,
},
testfn,
}
}
}