1
- use super :: { make_test, TestOptions } ;
1
+ use super :: { make_test, GlobalTestOptions } ;
2
2
use rustc_span:: edition:: DEFAULT_EDITION ;
3
3
4
4
#[ test]
5
5
fn make_test_basic ( ) {
6
6
//basic use: wraps with `fn main`, adds `#![allow(unused)]`
7
- let opts = TestOptions :: default ( ) ;
7
+ let opts = GlobalTestOptions :: default ( ) ;
8
8
let input = "assert_eq!(2+2, 4);" ;
9
9
let expected = "#![allow(unused)]
10
10
fn main() {
@@ -19,7 +19,7 @@ assert_eq!(2+2, 4);
19
19
fn make_test_crate_name_no_use ( ) {
20
20
// If you give a crate name but *don't* use it within the test, it won't bother inserting
21
21
// the `extern crate` statement.
22
- let opts = TestOptions :: default ( ) ;
22
+ let opts = GlobalTestOptions :: default ( ) ;
23
23
let input = "assert_eq!(2+2, 4);" ;
24
24
let expected = "#![allow(unused)]
25
25
fn main() {
@@ -34,7 +34,7 @@ assert_eq!(2+2, 4);
34
34
fn make_test_crate_name ( ) {
35
35
// If you give a crate name and use it within the test, it will insert an `extern crate`
36
36
// statement before `fn main`.
37
- let opts = TestOptions :: default ( ) ;
37
+ let opts = GlobalTestOptions :: default ( ) ;
38
38
let input = "use asdf::qwop;
39
39
assert_eq!(2+2, 4);" ;
40
40
let expected = "#![allow(unused)]
@@ -52,7 +52,7 @@ assert_eq!(2+2, 4);
52
52
fn make_test_no_crate_inject ( ) {
53
53
// Even if you do use the crate within the test, setting `opts.no_crate_inject` will skip
54
54
// adding it anyway.
55
- let opts = TestOptions { no_crate_inject : true , attrs : vec ! [ ] } ;
55
+ let opts = GlobalTestOptions { no_crate_inject : true , attrs : vec ! [ ] } ;
56
56
let input = "use asdf::qwop;
57
57
assert_eq!(2+2, 4);" ;
58
58
let expected = "#![allow(unused)]
@@ -70,7 +70,7 @@ fn make_test_ignore_std() {
70
70
// Even if you include a crate name, and use it in the doctest, we still won't include an
71
71
// `extern crate` statement if the crate is "std" -- that's included already by the
72
72
// compiler!
73
- let opts = TestOptions :: default ( ) ;
73
+ let opts = GlobalTestOptions :: default ( ) ;
74
74
let input = "use std::*;
75
75
assert_eq!(2+2, 4);" ;
76
76
let expected = "#![allow(unused)]
@@ -87,7 +87,7 @@ assert_eq!(2+2, 4);
87
87
fn make_test_manual_extern_crate ( ) {
88
88
// When you manually include an `extern crate` statement in your doctest, `make_test`
89
89
// assumes you've included one for your own crate too.
90
- let opts = TestOptions :: default ( ) ;
90
+ let opts = GlobalTestOptions :: default ( ) ;
91
91
let input = "extern crate asdf;
92
92
use asdf::qwop;
93
93
assert_eq!(2+2, 4);" ;
@@ -104,7 +104,7 @@ assert_eq!(2+2, 4);
104
104
105
105
#[ test]
106
106
fn make_test_manual_extern_crate_with_macro_use ( ) {
107
- let opts = TestOptions :: default ( ) ;
107
+ let opts = GlobalTestOptions :: default ( ) ;
108
108
let input = "#[macro_use] extern crate asdf;
109
109
use asdf::qwop;
110
110
assert_eq!(2+2, 4);" ;
@@ -123,7 +123,7 @@ assert_eq!(2+2, 4);
123
123
fn make_test_opts_attrs ( ) {
124
124
// If you supplied some doctest attributes with `#![doc(test(attr(...)))]`, it will use
125
125
// those instead of the stock `#![allow(unused)]`.
126
- let mut opts = TestOptions :: default ( ) ;
126
+ let mut opts = GlobalTestOptions :: default ( ) ;
127
127
opts. attrs . push ( "feature(sick_rad)" . to_string ( ) ) ;
128
128
let input = "use asdf::qwop;
129
129
assert_eq!(2+2, 4);" ;
@@ -155,7 +155,7 @@ assert_eq!(2+2, 4);
155
155
fn make_test_crate_attrs ( ) {
156
156
// Including inner attributes in your doctest will apply them to the whole "crate", pasting
157
157
// them outside the generated main function.
158
- let opts = TestOptions :: default ( ) ;
158
+ let opts = GlobalTestOptions :: default ( ) ;
159
159
let input = "#![feature(sick_rad)]
160
160
assert_eq!(2+2, 4);" ;
161
161
let expected = "#![allow(unused)]
@@ -171,7 +171,7 @@ assert_eq!(2+2, 4);
171
171
#[ test]
172
172
fn make_test_with_main ( ) {
173
173
// Including your own `fn main` wrapper lets the test use it verbatim.
174
- let opts = TestOptions :: default ( ) ;
174
+ let opts = GlobalTestOptions :: default ( ) ;
175
175
let input = "fn main() {
176
176
assert_eq!(2+2, 4);
177
177
}" ;
@@ -187,7 +187,7 @@ fn main() {
187
187
#[ test]
188
188
fn make_test_fake_main ( ) {
189
189
// ... but putting it in a comment will still provide a wrapper.
190
- let opts = TestOptions :: default ( ) ;
190
+ let opts = GlobalTestOptions :: default ( ) ;
191
191
let input = "//Ceci n'est pas une `fn main`
192
192
assert_eq!(2+2, 4);" ;
193
193
let expected = "#![allow(unused)]
@@ -203,7 +203,7 @@ assert_eq!(2+2, 4);
203
203
#[ test]
204
204
fn make_test_dont_insert_main ( ) {
205
205
// Even with that, if you set `dont_insert_main`, it won't create the `fn main` wrapper.
206
- let opts = TestOptions :: default ( ) ;
206
+ let opts = GlobalTestOptions :: default ( ) ;
207
207
let input = "//Ceci n'est pas une `fn main`
208
208
assert_eq!(2+2, 4);" ;
209
209
let expected = "#![allow(unused)]
@@ -216,7 +216,7 @@ assert_eq!(2+2, 4);"
216
216
217
217
#[ test]
218
218
fn make_test_issues_21299_33731 ( ) {
219
- let opts = TestOptions :: default ( ) ;
219
+ let opts = GlobalTestOptions :: default ( ) ;
220
220
221
221
let input = "// fn main
222
222
assert_eq!(2+2, 4);" ;
@@ -248,7 +248,7 @@ assert_eq!(asdf::foo, 4);
248
248
249
249
#[ test]
250
250
fn make_test_main_in_macro ( ) {
251
- let opts = TestOptions :: default ( ) ;
251
+ let opts = GlobalTestOptions :: default ( ) ;
252
252
let input = "#[macro_use] extern crate my_crate;
253
253
test_wrapper! {
254
254
fn main() {}
@@ -267,7 +267,7 @@ test_wrapper! {
267
267
#[ test]
268
268
fn make_test_returns_result ( ) {
269
269
// creates an inner function and unwraps it
270
- let opts = TestOptions :: default ( ) ;
270
+ let opts = GlobalTestOptions :: default ( ) ;
271
271
let input = "use std::io;
272
272
let mut input = String::new();
273
273
io::stdin().read_line(&mut input)?;
@@ -287,7 +287,7 @@ Ok::<(), io:Error>(())
287
287
#[ test]
288
288
fn make_test_named_wrapper ( ) {
289
289
// creates an inner function with a specific name
290
- let opts = TestOptions :: default ( ) ;
290
+ let opts = GlobalTestOptions :: default ( ) ;
291
291
let input = "assert_eq!(2+2, 4);" ;
292
292
let expected = "#![allow(unused)]
293
293
fn main() { #[allow(non_snake_case)] fn _doctest_main__some_unique_name() {
0 commit comments