13
13
14
14
// ignore-pretty
15
15
16
+ #![ feature( proc_macro_hygiene) ]
17
+
16
18
#[ macro_use]
17
19
extern crate span_test_macros;
18
20
19
21
extern crate span_api_tests;
20
22
21
- use span_api_tests:: { reemit, assert_fake_source_file, assert_source_file} ;
23
+ use span_api_tests:: { reemit, assert_fake_source_file, assert_source_file, macro_stringify } ;
22
24
23
25
macro_rules! say_hello {
24
26
( $macname: ident) => ( $macname! { "Hello, world!" } )
@@ -38,4 +40,32 @@ reemit! {
38
40
assert_source_file! { "Hello, world!" }
39
41
}
40
42
41
- fn main ( ) { }
43
+ fn main ( ) {
44
+ let s = macro_stringify ! ( Hello , world!) ;
45
+ assert_eq ! ( s, "Hello, world!" ) ;
46
+ assert_eq ! ( macro_stringify!( Hello , world!) , "Hello, world!" ) ;
47
+ assert_eq ! ( reemit_legacy!( macro_stringify!( Hello , world!) ) , "Hello, world!" ) ;
48
+ reemit_legacy ! ( assert_eq!( macro_stringify!( Hello , world!) , "Hello, world!" ) ) ;
49
+ // reemit change the span to be that of the call site
50
+ assert_eq ! (
51
+ reemit!( macro_stringify!( Hello , world!) ) ,
52
+ "reemit!(macro_stringify!(Hello, world!))"
53
+ ) ;
54
+ let r = "reemit!(assert_eq!(macro_stringify!(Hello, world!), r));" ;
55
+ reemit ! ( assert_eq!( macro_stringify!( Hello , world!) , r) ) ;
56
+
57
+ assert_eq ! ( macro_stringify!(
58
+ Hello ,
59
+ world!
60
+ ) , "Hello,\n world!" ) ;
61
+
62
+ assert_eq ! ( macro_stringify!( Hello , /*world */ !) , "Hello, /*world */ !" ) ;
63
+ assert_eq ! ( macro_stringify!(
64
+ Hello ,
65
+ // comment
66
+ world!
67
+ ) , "Hello,\n // comment\n world!" ) ;
68
+
69
+ assert_eq ! ( say_hello! { macro_stringify } , "\" Hello, world!\" " ) ;
70
+ assert_eq ! ( say_hello_extern! { macro_stringify } , "\" Hello, world!\" " ) ;
71
+ }
0 commit comments