1 #![allow(clippy::let_underscore_untyped)]
2 
3 use paste::paste;
4 use paste_test_suite::paste_test;
5 
6 #[test]
test_attr()7 fn test_attr() {
8     paste! {
9         #[paste_test(k = "val" "ue")]
10         struct A;
11 
12         #[paste_test_suite::paste_test(k = "val" "ue")]
13         struct B;
14 
15         #[::paste_test_suite::paste_test(k = "val" "ue")]
16         struct C;
17 
18         #[paste_test(k = "va" [<l u>] e)]
19         struct D;
20     }
21 
22     let _ = A;
23     let _ = B;
24     let _ = C;
25     let _ = D;
26 }
27 
28 #[test]
test_paste_cfg()29 fn test_paste_cfg() {
30     macro_rules! m {
31         ($ret:ident, $width:expr) => {
32             paste! {
33                 #[cfg(any(feature = "protocol_feature_" $ret:snake, target_pointer_width = "" $width))]
34                 fn new() -> $ret { todo!() }
35             }
36         };
37     }
38 
39     struct Paste;
40 
41     #[cfg(target_pointer_width = "64")]
42     m!(Paste, 64);
43     #[cfg(target_pointer_width = "32")]
44     m!(Paste, 32);
45 
46     let _ = new;
47 }
48 
49 #[test]
test_path_in_attr()50 fn test_path_in_attr() {
51     macro_rules! m {
52         (#[x = $x:ty]) => {
53             stringify!($x)
54         };
55     }
56 
57     let ty = paste! {
58         m!(#[x = foo::Bar])
59     };
60 
61     assert_eq!("foo::Bar", ty);
62 }
63