about summary refs log tree commit diff
path: root/library/test
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-06-20 16:39:52 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-08-13 20:14:56 +0200
commit1e1743a379885209ed969695d56762d38a9da09c (patch)
tree8531be5a518e02a75b866d6aba87a5419fe8a5de /library/test
parentd512438435aa1ee1731e2d5a45d01b6f14493e15 (diff)
downloadrust-1e1743a379885209ed969695d56762d38a9da09c.tar.gz
rust-1e1743a379885209ed969695d56762d38a9da09c.zip
Reduce merged doctest source code size
Diffstat (limited to 'library/test')
-rw-r--r--library/test/src/types.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/library/test/src/types.rs b/library/test/src/types.rs
index c3be3466cb9..802cab989c6 100644
--- a/library/test/src/types.rs
+++ b/library/test/src/types.rs
@@ -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,
+        }
+    }
+}