aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_srv/src/tests/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/proc_macro_srv/src/tests/mod.rs')
-rw-r--r--crates/proc_macro_srv/src/tests/mod.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/crates/proc_macro_srv/src/tests/mod.rs b/crates/proc_macro_srv/src/tests/mod.rs
new file mode 100644
index 000000000..1a827cbd7
--- /dev/null
+++ b/crates/proc_macro_srv/src/tests/mod.rs
@@ -0,0 +1,58 @@
1//! proc-macro tests
2
3#[macro_use]
4mod utils;
5use test_utils::assert_eq_text;
6use utils::*;
7
8#[test]
9fn test_derive_serialize_proc_macro() {
10 assert_expand(
11 "serde_derive",
12 "Serialize",
13 "1.0",
14 r"struct Foo {}",
15 include_str!("fixtures/test_serialize_proc_macro.txt"),
16 );
17}
18
19#[test]
20fn test_derive_serialize_proc_macro_failed() {
21 assert_expand(
22 "serde_derive",
23 "Serialize",
24 "1.0",
25 r"struct {}",
26 r##"
27SUBTREE $
28 IDENT compile_error 4294967295
29 PUNCH ! [alone] 4294967295
30 SUBTREE {} 4294967295
31 LITERAL "expected identifier" 4294967295
32"##,
33 );
34}
35
36#[test]
37fn test_derive_proc_macro_list() {
38 let res = list("serde_derive", "1").join("\n");
39
40 assert_eq_text!(
41 &res,
42 r#"Serialize [CustomDerive]
43Deserialize [CustomDerive]"#
44 );
45}
46
47/// Tests that we find and classify non-derive macros correctly.
48#[test]
49fn list_test_macros() {
50 let res = list("proc_macro_test", "0.0.0").join("\n");
51
52 assert_eq_text!(
53 &res,
54 r#"function_like_macro [FuncLike]
55attribute_macro [Attr]
56DummyTrait [CustomDerive]"#
57 );
58}