5 use expect_test::expect;
10 fn test_derive_empty() {
11 assert_expand("DeriveEmpty", r#"struct S;"#, expect![[r#"SUBTREE $"#]]);
15 fn test_derive_error() {
21 IDENT compile_error 4294967295
22 PUNCH ! [joint] 4294967295
24 LITERAL "#[derive(DeriveError)] struct S ;" 4294967295
25 PUNCH ; [alone] 4294967295"##]],
30 fn test_fn_like_macro_noop() {
36 IDENT ident 4294967295
37 PUNCH , [alone] 4294967295
39 PUNCH , [alone] 4294967295
41 PUNCH , [alone] 4294967295
42 SUBTREE [] 4294967295"#]],
47 fn test_fn_like_macro_clone_ident_subtree() {
49 "fn_like_clone_tokens",
53 IDENT ident 4294967295
54 PUNCH , [alone] 4294967295
55 SUBTREE [] 4294967295"#]],
60 fn test_fn_like_macro_clone_raw_ident() {
62 "fn_like_clone_tokens",
66 IDENT async 4294967295"#]],
71 fn test_fn_like_mk_literals() {
73 "fn_like_mk_literals",
77 LITERAL b"byte_string" 4294967295
78 LITERAL 'c' 4294967295
79 LITERAL "string" 4294967295
80 LITERAL 3.14f64 4294967295
81 LITERAL 3.14 4294967295
82 LITERAL 123i64 4294967295
83 LITERAL 123 4294967295"#]],
88 fn test_fn_like_mk_idents() {
89 // FIXME: this test is wrong: raw should be 'r#raw' but ABIs 1.64 and below
90 // simply ignore `is_raw` when implementing the `Ident` interface.
96 IDENT standard 4294967295
97 IDENT raw 4294967295"#]],
102 fn test_fn_like_macro_clone_literals() {
104 "fn_like_clone_tokens",
105 r#"1u16, 2_u32, -4i64, 3.14f32, "hello bridge""#,
108 LITERAL 1u16 4294967295
109 PUNCH , [alone] 4294967295
110 LITERAL 2_u32 4294967295
111 PUNCH , [alone] 4294967295
112 PUNCH - [joint] 4294967295
113 LITERAL 4i64 4294967295
114 PUNCH , [alone] 4294967295
115 LITERAL 3.14f32 4294967295
116 PUNCH , [alone] 4294967295
117 LITERAL "hello bridge" 4294967295"#]],
122 fn test_attr_macro() {
124 // #[proc_macro_test::attr_error(some arguments)]
132 IDENT compile_error 4294967295
133 PUNCH ! [joint] 4294967295
134 SUBTREE () 4294967295
135 LITERAL "#[attr_error(some arguments)] mod m {}" 4294967295
136 PUNCH ; [alone] 4294967295"##]],
140 /// Tests that we find and classify all proc macros correctly.
142 fn list_test_macros() {
143 let res = list().join("\n");
146 fn_like_noop [FuncLike]
147 fn_like_panic [FuncLike]
148 fn_like_error [FuncLike]
149 fn_like_clone_tokens [FuncLike]
150 fn_like_mk_literals [FuncLike]
151 fn_like_mk_idents [FuncLike]
155 DeriveEmpty [CustomDerive]
156 DerivePanic [CustomDerive]
157 DeriveError [CustomDerive]"#]]
162 fn test_version_check() {
163 let path = AbsPathBuf::assert(fixtures::proc_macro_test_dylib_path());
164 let info = proc_macro_api::read_dylib_info(&path).unwrap();
165 assert!(info.version.1 >= 50);