]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/issue-2973.rs
Rollup merge of #95040 - frank-king:fix/94981, r=Mark-Simulacrum
[rust.git] / src / tools / rustfmt / tests / target / issue-2973.rs
1 #[cfg(test)]
2 mod test {
3     summary_test! {
4         tokenize_recipe_interpolation_eol,
5     "foo: # some comment
6  {{hello}}
7 ",
8     "foo: \
9     {{hello}} \
10     {{ahah}}",
11         "N:#$>^{N}$<.",
12       }
13
14     summary_test! {
15       tokenize_strings,
16       r#"a = "'a'" + '"b"' + "'c'" + '"d"'#echo hello"#,
17       r#"N="+'+"+'#."#,
18     }
19
20     summary_test! {
21         tokenize_recipe_interpolation_eol,
22     "foo: # some comment
23  {{hello}}
24 ",
25         "N:#$>^{N}$<.",
26       }
27
28     summary_test! {
29         tokenize_recipe_interpolation_eof,
30     "foo: # more comments
31  {{hello}}
32 # another comment
33 ",
34         "N:#$>^{N}$<#$.",
35       }
36
37     summary_test! {
38       tokenize_recipe_complex_interpolation_expression,
39       "foo: #lol\n {{a + b + \"z\" + blarg}}",
40       "N:#$>^{N+N+\"+N}<.",
41     }
42
43     summary_test! {
44       tokenize_recipe_multiple_interpolations,
45       "foo:,#ok\n {{a}}0{{b}}1{{c}}",
46       "N:,#$>^{N}_{N}_{N}<.",
47     }
48
49     summary_test! {
50         tokenize_junk,
51     "bob
52
53 hello blah blah blah : a b c #whatever
54     ",
55         "N$$NNNN:NNN#$.",
56       }
57
58     summary_test! {
59         tokenize_empty_lines,
60     "
61 # this does something
62 hello:
63   asdf
64   bsdf
65
66   csdf
67
68   dsdf # whatever
69
70 # yolo
71   ",
72         "$#$N:$>^_$^_$$^_$$^_$$<#$.",
73       }
74
75     summary_test! {
76         tokenize_comment_before_variable,
77     "
78 #
79 A='1'
80 echo:
81   echo {{A}}
82   ",
83         "$#$N='$N:$>^_{N}$<.",
84       }
85
86     summary_test! {
87       tokenize_interpolation_backticks,
88       "hello:\n echo {{`echo hello` + `echo goodbye`}}",
89       "N:$>^_{`+`}<.",
90     }
91
92     summary_test! {
93       tokenize_assignment_backticks,
94       "a = `echo hello` + `echo goodbye`",
95       "N=`+`.",
96     }
97
98     summary_test! {
99         tokenize_multiple,
100     "
101 hello:
102   a
103   b
104
105   c
106
107   d
108
109 # hello
110 bob:
111   frank
112   ",
113
114         "$N:$>^_$^_$$^_$$^_$$<#$N:$>^_$<.",
115       }
116
117     summary_test! {
118       tokenize_comment,
119       "a:=#",
120       "N:=#."
121     }
122
123     summary_test! {
124       tokenize_comment_with_bang,
125       "a:=#foo!",
126       "N:=#."
127     }
128
129     summary_test! {
130         tokenize_order,
131     r"
132 b: a
133   @mv a b
134
135 a:
136   @touch F
137   @touch a
138
139 d: c
140   @rm c
141
142 c: b
143   @mv b c",
144         "$N:N$>^_$$<N:$>^_$^_$$<N:N$>^_$$<N:N$>^_<.",
145       }
146
147     summary_test! {
148       tokenize_parens,
149       r"((())) )abc(+",
150       "((())))N(+.",
151     }
152
153     summary_test! {
154       crlf_newline,
155       "#\r\n#asdf\r\n",
156       "#$#$.",
157     }
158 }