@@ -19,31 +19,30 @@ mod json_like {
19
19
20
20
#[ test]
21
21
fn json_like_proc_macro ( ) {
22
- json_like:: Value :: parse_with (
23
- quote:: quote! {
24
- // Example from `serde_json`.
25
- {
26
- name: "John Doe" ,
27
- age: 43 ,
28
- address: {
29
- street: "10 Downing Street" ,
30
- city: "London"
31
- } ,
32
- phones: [
33
- "+44 1234567" ,
34
- "+44 2345678"
35
- ] ,
22
+ let tokens: :: gll:: proc_macro:: TokenStream = quote:: quote! {
23
+ // Example from `serde_json`.
24
+ {
25
+ name: "John Doe" ,
26
+ age: 43 ,
27
+ address: {
28
+ street: "10 Downing Street" ,
29
+ city: "London"
30
+ } ,
31
+ phones: [
32
+ "+44 1234567" ,
33
+ "+44 2345678"
34
+ ] ,
36
35
37
- test: [ null, false , true , ( format!( "{:?}" , Some ( 1 + 2 ) ) ) ]
38
- }
39
- } ,
40
- |_, result| {
41
- let result = format ! ( "{:#?}" , result. unwrap( ) ) ;
42
- // HACK(eddyb) clean up the result, as we have no span info.
43
- let result = result
44
- . replace ( "Span..Span => " , "" )
45
- . replace ( "Span..Span" , "?" ) ;
46
- let expected = "\
36
+ test: [ null, false , true , ( format!( "{:?}" , Some ( 1 + 2 ) ) ) ]
37
+ }
38
+ } ;
39
+ json_like :: Value :: parse_with ( tokens , |_, result| {
40
+ let result = format ! ( "{:#?}" , result. unwrap( ) ) ;
41
+ // HACK(eddyb) clean up the result, as we have no span info.
42
+ let result = result
43
+ . replace ( "Span..Span => " , "" )
44
+ . replace ( "Span..Span" , "?" ) ;
45
+ let expected = "\
47
46
Value::Object {
48
47
fields: [
49
48
Field {
@@ -111,12 +110,11 @@ Value::Object {
111
110
}
112
111
]
113
112
}" ;
114
- assert ! (
115
- result == expected,
116
- "mismatched output, expected:\n {}\n \n found:\n {}" ,
117
- expected,
118
- result
119
- ) ;
120
- } ,
121
- )
113
+ assert ! (
114
+ result == expected,
115
+ "mismatched output, expected:\n {}\n \n found:\n {}" ,
116
+ expected,
117
+ result
118
+ ) ;
119
+ } )
122
120
}
0 commit comments