Debian Codegraph @

.cargo/vendor/syn/tests/test_shebang.rs

raw
1 #![allow(
2 clippy::elidable_lifetime_names,
3 clippy::needless_lifetimes,
4 clippy::uninlined_format_args
5 )]
6
7 #[macro_use]
8 mod snapshot;
9
10 mod debug;
11
12 #[test]
13 fn test_basic() {
14 let content = "#!/usr/bin/env rustx\nfn main() {}";
15 let file = syn::parse_file(content).unwrap();
16 snapshot!(file, @r##"
17 File {
18 shebang: Some("#!/usr/bin/env rustx"),
19 items: [
20 Item::Fn {
21 vis: Visibility::Inherited,
22 sig: Signature {
23 ident: "main",
24 generics: Generics,
25 output: ReturnType::Default,
26 },
27 block: Block {
28 stmts: [],
29 },
30 },
31 ],
32 }
33 "##);
34 }
35
36 #[test]
37 fn test_comment() {
38 let content = "#!//am/i/a/comment\n[allow(dead_code)] fn main() {}";
39 let file = syn::parse_file(content).unwrap();
40 snapshot!(file, @r#"
41 File {
42 attrs: [
43 Attribute {
44 style: AttrStyle::Inner,
45 meta: Meta::List {
46 path: Path {
47 segments: [
48 PathSegment {
49 ident: "allow",
50 },
51 ],
52 },
53 delimiter: MacroDelimiter::Paren,
54 tokens: TokenStream(`dead_code`),
55 },
56 },
57 ],
58 items: [
59 Item::Fn {
60 vis: Visibility::Inherited,
61 sig: Signature {
62 ident: "main",
63 generics: Generics,
64 output: ReturnType::Default,
65 },
66 block: Block {
67 stmts: [],
68 },
69 },
70 ],
71 }
72 "#);
73 }