Reduce merged doctest source code size · patricklam/verify-rust-std@0a6a74b (original) (raw)

Original file line number Diff line number Diff line change
@@ -250,3 +250,37 @@ pub struct TestDescAndFn {
250 250 pub desc: TestDesc,
251 251 pub testfn: TestFn,
252 252 }
253 +
254 +impl TestDescAndFn {
255 +pub const fn new_doctest(
256 +test_name: &'static str,
257 +ignore: bool,
258 +source_file: &'static str,
259 +start_line: usize,
260 +no_run: bool,
261 +should_panic: bool,
262 +testfn: TestFn,
263 +) -> Self {
264 +Self {
265 +desc: TestDesc {
266 +name: StaticTestName(test_name),
267 + ignore,
268 +ignore_message: None,
269 + source_file,
270 + start_line,
271 +start_col: 0,
272 +end_line: 0,
273 +end_col: 0,
274 +compile_fail: false,
275 + no_run,
276 +should_panic: if should_panic {
277 + options::ShouldPanic::Yes
278 +} else {
279 + options::ShouldPanic::No
280 +},
281 +test_type: TestType::DocTest,
282 +},
283 + testfn,
284 +}
285 +}
286 +}