1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
//! proc-macro tests
#[macro_use]
mod utils;
use test_utils::assert_eq_text;
use utils::*;
#[test]
fn test_derive_serialize_proc_macro() {
assert_expand(
"serde_derive",
"Serialize",
"1.0",
r"struct Foo {}",
include_str!("fixtures/test_serialize_proc_macro.txt"),
);
}
#[test]
fn test_derive_serialize_proc_macro_failed() {
assert_expand(
"serde_derive",
"Serialize",
"1.0",
r"struct {}",
r##"
SUBTREE $
IDENT compile_error 4294967295
PUNCH ! [alone] 4294967295
SUBTREE {} 4294967295
LITERAL "expected identifier" 4294967295
"##,
);
}
#[test]
fn test_derive_proc_macro_list() {
let res = list("serde_derive", "1").join("\n");
assert_eq_text!(
r#"Serialize [CustomDerive]
Deserialize [CustomDerive]"#,
&res
);
}
/// Tests that we find and classify non-derive macros correctly.
#[test]
fn list_test_macros() {
let res = list("proc_macro_test", "0.0.0").join("\n");
assert_eq_text!(
r#"function_like_macro [FuncLike]
attribute_macro [Attr]
DummyTrait [CustomDerive]"#,
&res
);
}
|