@@ -39,16 +39,23 @@ fn test_warning_for_int56_without_strict() {
3939 return int64(a);
4040 }
4141 }"# ;
42-
42+
4343 let diagnostics = build_with_strict_soroban_types ( src, false ) ;
44-
44+
4545 // Should have a warning about int56 being rounded to int64
46- let warnings: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning ) . collect ( ) ;
46+ let warnings: Vec < _ > = diagnostics
47+ . iter ( )
48+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning )
49+ . collect ( ) ;
4750 assert ! ( !warnings. is_empty( ) , "Expected warnings for int56 rounding" ) ;
48-
51+
4952 let warning_messages: Vec < _ > = warnings. iter ( ) . map ( |w| w. message . as_str ( ) ) . collect ( ) ;
50- assert ! ( warning_messages. iter( ) . any( |msg| msg. contains( "int56" ) && msg. contains( "int64" ) ) ,
51- "Expected warning about int56 being rounded to int64" ) ;
53+ assert ! (
54+ warning_messages
55+ . iter( )
56+ . any( |msg| msg. contains( "int56" ) && msg. contains( "int64" ) ) ,
57+ "Expected warning about int56 being rounded to int64"
58+ ) ;
5259}
5360
5461#[ test]
@@ -58,16 +65,26 @@ fn test_warning_for_uint56_without_strict() {
5865 return uint64(a);
5966 }
6067 }"# ;
61-
68+
6269 let diagnostics = build_with_strict_soroban_types ( src, false ) ;
63-
70+
6471 // Should have a warning about uint56 being rounded to uint64
65- let warnings: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning ) . collect ( ) ;
66- assert ! ( !warnings. is_empty( ) , "Expected warnings for uint56 rounding" ) ;
67-
72+ let warnings: Vec < _ > = diagnostics
73+ . iter ( )
74+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning )
75+ . collect ( ) ;
76+ assert ! (
77+ !warnings. is_empty( ) ,
78+ "Expected warnings for uint56 rounding"
79+ ) ;
80+
6881 let warning_messages: Vec < _ > = warnings. iter ( ) . map ( |w| w. message . as_str ( ) ) . collect ( ) ;
69- assert ! ( warning_messages. iter( ) . any( |msg| msg. contains( "uint56" ) && msg. contains( "uint64" ) ) ,
70- "Expected warning about uint56 being rounded to uint64" ) ;
82+ assert ! (
83+ warning_messages
84+ . iter( )
85+ . any( |msg| msg. contains( "uint56" ) && msg. contains( "uint64" ) ) ,
86+ "Expected warning about uint56 being rounded to uint64"
87+ ) ;
7188}
7289
7390#[ test]
@@ -77,16 +94,23 @@ fn test_warning_for_int96_without_strict() {
7794 return int128(a);
7895 }
7996 }"# ;
80-
97+
8198 let diagnostics = build_with_strict_soroban_types ( src, false ) ;
82-
99+
83100 // Should have a warning about int96 being rounded to int128
84- let warnings: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning ) . collect ( ) ;
101+ let warnings: Vec < _ > = diagnostics
102+ . iter ( )
103+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning )
104+ . collect ( ) ;
85105 assert ! ( !warnings. is_empty( ) , "Expected warnings for int96 rounding" ) ;
86-
106+
87107 let warning_messages: Vec < _ > = warnings. iter ( ) . map ( |w| w. message . as_str ( ) ) . collect ( ) ;
88- assert ! ( warning_messages. iter( ) . any( |msg| msg. contains( "int96" ) && msg. contains( "int128" ) ) ,
89- "Expected warning about int96 being rounded to int128" ) ;
108+ assert ! (
109+ warning_messages
110+ . iter( )
111+ . any( |msg| msg. contains( "int96" ) && msg. contains( "int128" ) ) ,
112+ "Expected warning about int96 being rounded to int128"
113+ ) ;
90114}
91115
92116#[ test]
@@ -96,16 +120,26 @@ fn test_warning_for_uint96_without_strict() {
96120 return uint128(a);
97121 }
98122 }"# ;
99-
123+
100124 let diagnostics = build_with_strict_soroban_types ( src, false ) ;
101-
125+
102126 // Should have a warning about uint96 being rounded to uint128
103- let warnings: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning ) . collect ( ) ;
104- assert ! ( !warnings. is_empty( ) , "Expected warnings for uint96 rounding" ) ;
105-
127+ let warnings: Vec < _ > = diagnostics
128+ . iter ( )
129+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Warning )
130+ . collect ( ) ;
131+ assert ! (
132+ !warnings. is_empty( ) ,
133+ "Expected warnings for uint96 rounding"
134+ ) ;
135+
106136 let warning_messages: Vec < _ > = warnings. iter ( ) . map ( |w| w. message . as_str ( ) ) . collect ( ) ;
107- assert ! ( warning_messages. iter( ) . any( |msg| msg. contains( "uint96" ) && msg. contains( "uint128" ) ) ,
108- "Expected warning about uint96 being rounded to uint128" ) ;
137+ assert ! (
138+ warning_messages
139+ . iter( )
140+ . any( |msg| msg. contains( "uint96" ) && msg. contains( "uint128" ) ) ,
141+ "Expected warning about uint96 being rounded to uint128"
142+ ) ;
109143}
110144
111145#[ test]
@@ -115,16 +149,26 @@ fn test_error_for_int56_with_strict() {
115149 return int64(a);
116150 }
117151 }"# ;
118-
152+
119153 let diagnostics = build_with_strict_soroban_types ( src, true ) ;
120-
154+
121155 // Should have an error about int56 being rounded to int64
122- let errors: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error ) . collect ( ) ;
123- assert ! ( !errors. is_empty( ) , "Expected errors for int56 rounding with strict mode" ) ;
124-
156+ let errors: Vec < _ > = diagnostics
157+ . iter ( )
158+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error )
159+ . collect ( ) ;
160+ assert ! (
161+ !errors. is_empty( ) ,
162+ "Expected errors for int56 rounding with strict mode"
163+ ) ;
164+
125165 let error_messages: Vec < _ > = errors. iter ( ) . map ( |e| e. message . as_str ( ) ) . collect ( ) ;
126- assert ! ( error_messages. iter( ) . any( |msg| msg. contains( "int56" ) && msg. contains( "int64" ) ) ,
127- "Expected error about int56 being rounded to int64" ) ;
166+ assert ! (
167+ error_messages
168+ . iter( )
169+ . any( |msg| msg. contains( "int56" ) && msg. contains( "int64" ) ) ,
170+ "Expected error about int56 being rounded to int64"
171+ ) ;
128172}
129173
130174#[ test]
@@ -134,16 +178,26 @@ fn test_error_for_uint56_with_strict() {
134178 return uint64(a);
135179 }
136180 }"# ;
137-
181+
138182 let diagnostics = build_with_strict_soroban_types ( src, true ) ;
139-
183+
140184 // Should have an error about uint56 being rounded to uint64
141- let errors: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error ) . collect ( ) ;
142- assert ! ( !errors. is_empty( ) , "Expected errors for uint56 rounding with strict mode" ) ;
143-
185+ let errors: Vec < _ > = diagnostics
186+ . iter ( )
187+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error )
188+ . collect ( ) ;
189+ assert ! (
190+ !errors. is_empty( ) ,
191+ "Expected errors for uint56 rounding with strict mode"
192+ ) ;
193+
144194 let error_messages: Vec < _ > = errors. iter ( ) . map ( |e| e. message . as_str ( ) ) . collect ( ) ;
145- assert ! ( error_messages. iter( ) . any( |msg| msg. contains( "uint56" ) && msg. contains( "uint64" ) ) ,
146- "Expected error about uint56 being rounded to uint64" ) ;
195+ assert ! (
196+ error_messages
197+ . iter( )
198+ . any( |msg| msg. contains( "uint56" ) && msg. contains( "uint64" ) ) ,
199+ "Expected error about uint56 being rounded to uint64"
200+ ) ;
147201}
148202
149203#[ test]
@@ -153,16 +207,26 @@ fn test_error_for_int96_with_strict() {
153207 return int128(a);
154208 }
155209 }"# ;
156-
210+
157211 let diagnostics = build_with_strict_soroban_types ( src, true ) ;
158-
212+
159213 // Should have an error about int96 being rounded to int128
160- let errors: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error ) . collect ( ) ;
161- assert ! ( !errors. is_empty( ) , "Expected errors for int96 rounding with strict mode" ) ;
162-
214+ let errors: Vec < _ > = diagnostics
215+ . iter ( )
216+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error )
217+ . collect ( ) ;
218+ assert ! (
219+ !errors. is_empty( ) ,
220+ "Expected errors for int96 rounding with strict mode"
221+ ) ;
222+
163223 let error_messages: Vec < _ > = errors. iter ( ) . map ( |e| e. message . as_str ( ) ) . collect ( ) ;
164- assert ! ( error_messages. iter( ) . any( |msg| msg. contains( "int96" ) && msg. contains( "int128" ) ) ,
165- "Expected error about int96 being rounded to int128" ) ;
224+ assert ! (
225+ error_messages
226+ . iter( )
227+ . any( |msg| msg. contains( "int96" ) && msg. contains( "int128" ) ) ,
228+ "Expected error about int96 being rounded to int128"
229+ ) ;
166230}
167231
168232#[ test]
@@ -172,16 +236,26 @@ fn test_error_for_uint96_with_strict() {
172236 return uint128(a);
173237 }
174238 }"# ;
175-
239+
176240 let diagnostics = build_with_strict_soroban_types ( src, true ) ;
177-
241+
178242 // Should have an error about uint96 being rounded to uint128
179- let errors: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error ) . collect ( ) ;
180- assert ! ( !errors. is_empty( ) , "Expected errors for uint96 rounding with strict mode" ) ;
181-
243+ let errors: Vec < _ > = diagnostics
244+ . iter ( )
245+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error )
246+ . collect ( ) ;
247+ assert ! (
248+ !errors. is_empty( ) ,
249+ "Expected errors for uint96 rounding with strict mode"
250+ ) ;
251+
182252 let error_messages: Vec < _ > = errors. iter ( ) . map ( |e| e. message . as_str ( ) ) . collect ( ) ;
183- assert ! ( error_messages. iter( ) . any( |msg| msg. contains( "uint96" ) && msg. contains( "uint128" ) ) ,
184- "Expected error about uint96 being rounded to uint128" ) ;
253+ assert ! (
254+ error_messages
255+ . iter( )
256+ . any( |msg| msg. contains( "uint96" ) && msg. contains( "uint128" ) ) ,
257+ "Expected error about uint96 being rounded to uint128"
258+ ) ;
185259}
186260
187261#[ test]
@@ -191,16 +265,26 @@ fn test_error_for_int200_with_strict() {
191265 return int256(a);
192266 }
193267 }"# ;
194-
268+
195269 let diagnostics = build_with_strict_soroban_types ( src, true ) ;
196-
270+
197271 // Should have an error about int200 being rounded to int256
198- let errors: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error ) . collect ( ) ;
199- assert ! ( !errors. is_empty( ) , "Expected errors for int200 rounding with strict mode" ) ;
200-
272+ let errors: Vec < _ > = diagnostics
273+ . iter ( )
274+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error )
275+ . collect ( ) ;
276+ assert ! (
277+ !errors. is_empty( ) ,
278+ "Expected errors for int200 rounding with strict mode"
279+ ) ;
280+
201281 let error_messages: Vec < _ > = errors. iter ( ) . map ( |e| e. message . as_str ( ) ) . collect ( ) ;
202- assert ! ( error_messages. iter( ) . any( |msg| msg. contains( "int200" ) && msg. contains( "int256" ) ) ,
203- "Expected error about int200 being rounded to int256" ) ;
282+ assert ! (
283+ error_messages
284+ . iter( )
285+ . any( |msg| msg. contains( "int200" ) && msg. contains( "int256" ) ) ,
286+ "Expected error about int200 being rounded to int256"
287+ ) ;
204288}
205289
206290#[ test]
@@ -210,14 +294,24 @@ fn test_error_for_uint200_with_strict() {
210294 return uint256(a);
211295 }
212296 }"# ;
213-
297+
214298 let diagnostics = build_with_strict_soroban_types ( src, true ) ;
215-
299+
216300 // Should have an error about uint200 being rounded to uint256
217- let errors: Vec < _ > = diagnostics. iter ( ) . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error ) . collect ( ) ;
218- assert ! ( !errors. is_empty( ) , "Expected errors for uint200 rounding with strict mode" ) ;
219-
301+ let errors: Vec < _ > = diagnostics
302+ . iter ( )
303+ . filter ( |d| d. level == solang_parser:: diagnostics:: Level :: Error )
304+ . collect ( ) ;
305+ assert ! (
306+ !errors. is_empty( ) ,
307+ "Expected errors for uint200 rounding with strict mode"
308+ ) ;
309+
220310 let error_messages: Vec < _ > = errors. iter ( ) . map ( |e| e. message . as_str ( ) ) . collect ( ) ;
221- assert ! ( error_messages. iter( ) . any( |msg| msg. contains( "uint200" ) && msg. contains( "uint256" ) ) ,
222- "Expected error about uint200 being rounded to uint256" ) ;
311+ assert ! (
312+ error_messages
313+ . iter( )
314+ . any( |msg| msg. contains( "uint200" ) && msg. contains( "uint256" ) ) ,
315+ "Expected error about uint200 being rounded to uint256"
316+ ) ;
223317}
0 commit comments