@@ -295,6 +295,64 @@ BOOST_AUTO_TEST_CASE(if_statement)
295
295
BOOST_CHECK (successParse (" { function f() -> x:bool {} if f() { let b:bool := f() } }" ));
296
296
}
297
297
298
+ BOOST_AUTO_TEST_CASE (for_statement)
299
+ {
300
+ auto dialect = EVMDialect::strictAssemblyForEVMObjects (EVMVersion::constantinople ());
301
+ BOOST_CHECK (successParse (" { for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {} }" , dialect));
302
+ }
303
+
304
+ BOOST_AUTO_TEST_CASE (for_statement_break)
305
+ {
306
+ auto dialect = EVMDialect::strictAssemblyForEVMObjects (EVMVersion::constantinople ());
307
+ BOOST_CHECK (successParse (" { for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {break} }" , dialect));
308
+ }
309
+
310
+ BOOST_AUTO_TEST_CASE (for_statement_break_init)
311
+ {
312
+ auto dialect = EVMDialect::strictAssemblyForEVMObjects (EVMVersion::constantinople ());
313
+ CHECK_ERROR_DIALECT (
314
+ " { for {let i := 0 break} iszero(eq(i, 10)) {i := add(i, 1)} {} }" ,
315
+ SyntaxError,
316
+ " Keyword break outside for-loop body is not allowed." ,
317
+ dialect);
318
+ }
319
+
320
+ BOOST_AUTO_TEST_CASE (for_statement_break_post)
321
+ {
322
+ auto dialect = EVMDialect::strictAssemblyForEVMObjects (EVMVersion::constantinople ());
323
+ CHECK_ERROR_DIALECT (
324
+ " { for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1) break} {} }" ,
325
+ SyntaxError,
326
+ " Keyword break outside for-loop body is not allowed." ,
327
+ dialect);
328
+ }
329
+
330
+ BOOST_AUTO_TEST_CASE (for_statement_continue)
331
+ {
332
+ auto dialect = EVMDialect::strictAssemblyForEVMObjects (EVMVersion::constantinople ());
333
+ BOOST_CHECK (successParse (" { for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {continue} }" , dialect));
334
+ }
335
+
336
+ BOOST_AUTO_TEST_CASE (for_statement_continue_fail_init)
337
+ {
338
+ auto dialect = EVMDialect::strictAssemblyForEVMObjects (EVMVersion::constantinople ());
339
+ CHECK_ERROR_DIALECT (
340
+ " { for {let i := 0 continue} iszero(eq(i, 10)) {i := add(i, 1)} {} }" ,
341
+ SyntaxError,
342
+ " Keyword continue outside for-loop body is not allowed." ,
343
+ dialect);
344
+ }
345
+
346
+ BOOST_AUTO_TEST_CASE (for_statement_continue_fail_post)
347
+ {
348
+ auto dialect = EVMDialect::strictAssemblyForEVMObjects (EVMVersion::constantinople ());
349
+ CHECK_ERROR_DIALECT (
350
+ " { for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1) continue} {} }" ,
351
+ SyntaxError,
352
+ " Keyword continue outside for-loop body is not allowed." ,
353
+ dialect);
354
+ }
355
+
298
356
BOOST_AUTO_TEST_CASE (if_statement_invalid)
299
357
{
300
358
CHECK_ERROR (" { if let x:u256 {} }" , ParserError, " Literal or identifier expected." );
0 commit comments