@@ -53,7 +53,8 @@ assert_eq!(2+2, 4);
5353fn make_test_no_crate_inject ( ) {
5454 // Even if you do use the crate within the test, setting `opts.no_crate_inject` will skip
5555 // adding it anyway.
56- let opts = GlobalTestOptions { no_crate_inject : true , attrs : vec ! [ ] } ;
56+ let opts =
57+ GlobalTestOptions { no_crate_inject : true , attrs : vec ! [ ] , insert_indent_space : false } ;
5758 let input = "use asdf::qwop;
5859assert_eq!(2+2, 4);" ;
5960 let expected = "#![allow(unused)]
@@ -302,3 +303,44 @@ assert_eq!(2+2, 4);
302303 make_test ( input, None , false , & opts, DEFAULT_EDITION , Some ( "_some_unique_name" ) ) ;
303304 assert_eq ! ( ( output, len) , ( expected, 2 ) ) ;
304305}
306+
307+ #[ test]
308+ fn make_test_insert_extra_space ( ) {
309+ // will insert indent spaces in the code block if `insert_indent_space` is true
310+ let opts =
311+ GlobalTestOptions { no_crate_inject : false , attrs : vec ! [ ] , insert_indent_space : true } ;
312+ let input = "use std::*;
313+ assert_eq!(2+2, 4);
314+ eprintln!(\" hello anan\" );
315+ " ;
316+ let expected = "#![allow(unused)]
317+ fn main() {
318+ use std::*;
319+ assert_eq!(2+2, 4);
320+ eprintln!(\" hello anan\" );
321+ }"
322+ . to_string ( ) ;
323+ let ( output, len, _) = make_test ( input, None , false , & opts, DEFAULT_EDITION , None ) ;
324+ assert_eq ! ( ( output, len) , ( expected, 2 ) ) ;
325+ }
326+
327+ #[ test]
328+ fn make_test_insert_extra_space_fn_main ( ) {
329+ // if input already has a fn main, it should insert a space before it
330+ let opts =
331+ GlobalTestOptions { no_crate_inject : false , attrs : vec ! [ ] , insert_indent_space : true } ;
332+ let input = "use std::*;
333+ fn main() {
334+ assert_eq!(2+2, 4);
335+ eprintln!(\" hello anan\" );
336+ }" ;
337+ let expected = "#![allow(unused)]
338+ use std::*;
339+ fn main() {
340+ assert_eq!(2+2, 4);
341+ eprintln!(\" hello anan\" );
342+ }"
343+ . to_string ( ) ;
344+ let ( output, len, _) = make_test ( input, None , false , & opts, DEFAULT_EDITION , None ) ;
345+ assert_eq ! ( ( output, len) , ( expected, 1 ) ) ;
346+ }
0 commit comments