@@ -15,22 +15,18 @@ fn test_format_title() {
15
15
slices : vec ! [ ] ,
16
16
} ;
17
17
let output = dl:: DisplayList {
18
- body : vec ! [
19
- dl:: DisplayLine :: Raw ( dl:: DisplayRawLine :: Annotation {
20
- annotation: dl:: Annotation {
21
- annotation_type: dl:: DisplayAnnotationType :: Error ,
22
- id: Some ( "E0001" . to_string( ) ) ,
23
- label: vec![
24
- dl:: DisplayTextFragment {
25
- content: "This is a title" . to_string( ) ,
26
- style: dl:: DisplayTextStyle :: Emphasis ,
27
- } ,
28
- ] ,
29
- } ,
30
- source_aligned: false ,
31
- continuation: false ,
32
- } ) ,
33
- ] ,
18
+ body : vec ! [ dl:: DisplayLine :: Raw ( dl:: DisplayRawLine :: Annotation {
19
+ annotation: dl:: Annotation {
20
+ annotation_type: dl:: DisplayAnnotationType :: Error ,
21
+ id: Some ( "E0001" . to_string( ) ) ,
22
+ label: vec![ dl:: DisplayTextFragment {
23
+ content: "This is a title" . to_string( ) ,
24
+ style: dl:: DisplayTextStyle :: Emphasis ,
25
+ } ] ,
26
+ } ,
27
+ source_aligned: false ,
28
+ continuation: false ,
29
+ } ) ] ,
34
30
} ;
35
31
assert_eq ! ( dl:: DisplayList :: from( input) , output) ;
36
32
}
@@ -40,15 +36,13 @@ fn test_format_slice() {
40
36
let input = snippet:: Snippet {
41
37
title : None ,
42
38
footer : vec ! [ ] ,
43
- slices : vec ! [
44
- snippet:: Slice {
45
- source: "This is line 1\n This is line 2" . to_string( ) ,
46
- line_start: 5402 ,
47
- origin: None ,
48
- annotations: vec![ ] ,
49
- fold: false ,
50
- } ,
51
- ] ,
39
+ slices : vec ! [ snippet:: Slice {
40
+ source: "This is line 1\n This is line 2" . to_string( ) ,
41
+ line_start: 5402 ,
42
+ origin: None ,
43
+ annotations: vec![ ] ,
44
+ fold: false ,
45
+ } ] ,
52
46
} ;
53
47
let output = dl:: DisplayList {
54
48
body : vec ! [
@@ -163,21 +157,17 @@ fn test_format_slice_annotation_standalone() {
163
157
let input = snippet:: Snippet {
164
158
title : None ,
165
159
footer : vec ! [ ] ,
166
- slices : vec ! [
167
- snippet:: Slice {
168
- source: "This is line 1\n This is line 2" . to_string( ) ,
169
- line_start: 5402 ,
170
- origin: None ,
171
- annotations: vec![
172
- snippet:: SourceAnnotation {
173
- range: ( 22 , 24 ) ,
174
- label: "Test annotation" . to_string( ) ,
175
- annotation_type: snippet:: AnnotationType :: Info ,
176
- } ,
177
- ] ,
178
- fold: false ,
179
- } ,
180
- ] ,
160
+ slices : vec ! [ snippet:: Slice {
161
+ source: "This is line 1\n This is line 2" . to_string( ) ,
162
+ line_start: 5402 ,
163
+ origin: None ,
164
+ annotations: vec![ snippet:: SourceAnnotation {
165
+ range: ( 22 , 24 ) ,
166
+ label: "Test annotation" . to_string( ) ,
167
+ annotation_type: snippet:: AnnotationType :: Info ,
168
+ } ] ,
169
+ fold: false ,
170
+ } ] ,
181
171
} ;
182
172
let output = dl:: DisplayList {
183
173
body : vec ! [
@@ -209,12 +199,10 @@ fn test_format_slice_annotation_standalone() {
209
199
annotation: dl:: Annotation {
210
200
annotation_type: dl:: DisplayAnnotationType :: Info ,
211
201
id: None ,
212
- label: vec![
213
- dl:: DisplayTextFragment {
214
- content: "Test annotation" . to_string( ) ,
215
- style: dl:: DisplayTextStyle :: Regular ,
216
- } ,
217
- ] ,
202
+ label: vec![ dl:: DisplayTextFragment {
203
+ content: "Test annotation" . to_string( ) ,
204
+ style: dl:: DisplayTextStyle :: Regular ,
205
+ } ] ,
218
206
} ,
219
207
range: ( 6 , 8 ) ,
220
208
annotation_type: dl:: DisplayAnnotationType :: Info ,
@@ -235,40 +223,36 @@ fn test_format_slice_annotation_standalone() {
235
223
fn test_format_label ( ) {
236
224
let input = snippet:: Snippet {
237
225
title : None ,
238
- footer : vec ! [
239
- snippet:: Annotation {
240
- id: None ,
241
- label: Some ( "This __is__ a title" . to_string( ) ) ,
242
- annotation_type: snippet:: AnnotationType :: Error ,
243
- } ,
244
- ] ,
226
+ footer : vec ! [ snippet:: Annotation {
227
+ id: None ,
228
+ label: Some ( "This __is__ a title" . to_string( ) ) ,
229
+ annotation_type: snippet:: AnnotationType :: Error ,
230
+ } ] ,
245
231
slices : vec ! [ ] ,
246
232
} ;
247
233
let output = dl:: DisplayList {
248
- body : vec ! [
249
- dl:: DisplayLine :: Raw ( dl:: DisplayRawLine :: Annotation {
250
- annotation: dl:: Annotation {
251
- annotation_type: dl:: DisplayAnnotationType :: Error ,
252
- id: None ,
253
- label: vec![
254
- dl:: DisplayTextFragment {
255
- content: "This " . to_string( ) ,
256
- style: dl:: DisplayTextStyle :: Regular ,
257
- } ,
258
- dl:: DisplayTextFragment {
259
- content: "is" . to_string( ) ,
260
- style: dl:: DisplayTextStyle :: Emphasis ,
261
- } ,
262
- dl:: DisplayTextFragment {
263
- content: " a title" . to_string( ) ,
264
- style: dl:: DisplayTextStyle :: Regular ,
265
- } ,
266
- ] ,
267
- } ,
268
- source_aligned: true ,
269
- continuation: false ,
270
- } ) ,
271
- ] ,
234
+ body : vec ! [ dl:: DisplayLine :: Raw ( dl:: DisplayRawLine :: Annotation {
235
+ annotation: dl:: Annotation {
236
+ annotation_type: dl:: DisplayAnnotationType :: Error ,
237
+ id: None ,
238
+ label: vec![
239
+ dl:: DisplayTextFragment {
240
+ content: "This " . to_string( ) ,
241
+ style: dl:: DisplayTextStyle :: Regular ,
242
+ } ,
243
+ dl:: DisplayTextFragment {
244
+ content: "is" . to_string( ) ,
245
+ style: dl:: DisplayTextStyle :: Emphasis ,
246
+ } ,
247
+ dl:: DisplayTextFragment {
248
+ content: " a title" . to_string( ) ,
249
+ style: dl:: DisplayTextStyle :: Regular ,
250
+ } ,
251
+ ] ,
252
+ } ,
253
+ source_aligned: true ,
254
+ continuation: false ,
255
+ } ) ] ,
272
256
} ;
273
257
assert_eq ! ( dl:: DisplayList :: from( input) , output) ;
274
258
}
0 commit comments