@@ -436,19 +436,25 @@ BOOST_AUTO_TEST_CASE(default_optimiser_sequence)
436
436
BOOST_AUTO_TEST_CASE (valid_optimiser_sequences)
437
437
{
438
438
vector<string> validSequenceInputs {
439
- " :" , // Empty optimization sequence and empty cleanup sequence
440
- " :fDn" , // Empty optimization sequence and specified cleanup sequence
441
- " dhfoDgvulfnTUtnIf:" , // Specified optimization sequence and empty cleanup sequence
442
- " dhfoDgvulfnTUtnIf:fDn" , // Specified optimization sequence and cleanup sequence
443
- " dhfo[Dgvulfn]TUtnIf:f[D]n" // Specified and nested optimization and cleanup sequence
439
+ " :" , // Empty optimization sequence and empty cleanup sequence
440
+ " :fDn" , // Empty optimization sequence and specified cleanup sequence
441
+ " dhfoDgvulfnTUtnIf:" , // Specified optimization sequence and empty cleanup sequence
442
+ " dhfoDgvulfnTUtnIf:fDn" , // Specified optimization sequence and cleanup sequence
443
+ " dhfo[Dgvulfn]TUtnIf:f[D]n" , // Specified and nested optimization and cleanup sequence
444
+ " dhfoDgvulfnTUtnIf" , // Specified optimizer sequence only
445
+ " iDu" , // Short optimizer sequence
446
+ " a[[a][[aa]aa[aa]][]]aaa[aa[aa[aa]]]a[a][a][a]a[a]" // Nested brackets
444
447
};
445
448
446
- vector<tuple<string, string>> expectedParsedSequences {
449
+ vector<tuple<string, string>> const expectedParsedSequences {
447
450
{" " , " " },
448
451
{" " , " fDn" },
449
452
{" dhfoDgvulfnTUtnIf" , " " },
450
453
{" dhfoDgvulfnTUtnIf" , " fDn" },
451
- {" dhfo[Dgvulfn]TUtnIf" , " f[D]n" }
454
+ {" dhfo[Dgvulfn]TUtnIf" , " f[D]n" },
455
+ {" dhfoDgvulfnTUtnIf" , OptimiserSettings::DefaultYulOptimiserCleanupSteps},
456
+ {" iDu" , OptimiserSettings::DefaultYulOptimiserCleanupSteps},
457
+ {" a[[a][[aa]aa[aa]][]]aaa[aa[aa[aa]]]a[a][a][a]a[a]" , OptimiserSettings::DefaultYulOptimiserCleanupSteps}
452
458
};
453
459
454
460
BOOST_CHECK_EQUAL (validSequenceInputs.size (), expectedParsedSequences.size ());
@@ -462,20 +468,46 @@ BOOST_AUTO_TEST_CASE(valid_optimiser_sequences)
462
468
}
463
469
}
464
470
465
- BOOST_AUTO_TEST_CASE (invalid_nested_cleanup_sequence_delimiter )
471
+ BOOST_AUTO_TEST_CASE (invalid_optimiser_sequences )
466
472
{
467
- vector<string> commandLine {" solc" , " contract.sol" , " --optimize" , " --yul-optimizations=dhfoDgvulfnTUt[nIf:fd]N" };
468
- string expectedMessage = " Invalid optimizer step sequence in --yul-optimizations: Cleanup sequence delimiter cannot be placed inside the brackets" ;
469
- auto hasCorrectMessage = [&](CommandLineValidationError const & _exception) { return _exception.what () == expectedMessage; };
470
- BOOST_CHECK_EXCEPTION (parseCommandLine (commandLine), CommandLineValidationError, hasCorrectMessage);
471
- }
473
+ vector<string> const invalidSequenceInputs {
474
+ " abcdefg{hijklmno}pqr[st]uvwxyz" , // Invalid abbreviation
475
+ " [[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
476
+ " [[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
477
+ " [[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
478
+ " [[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
479
+ " [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[a]"
480
+ " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
481
+ " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
482
+ " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
483
+ " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
484
+ " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]" , // Brackets nested too deep
485
+ " a]a][" , // Unbalanced closing bracket
486
+ " a[a][" , // Unbalanced opening bracket
487
+ " dhfoDgvulfnTUt[nIf:fd]N" , // Nested cleanup sequence delimiter
488
+ " dhfoDgvulfnTU:tnIf:fdN" // Too many cleanup sequence delimiters
489
+ };
472
490
473
- BOOST_AUTO_TEST_CASE (too_many_cleanup_sequence_delimiters)
474
- {
475
- vector<string> commandLine {" solc" , " contract.sol" , " --optimize" , " --yul-optimizations=dhfoDgvulfnTU:tnIf:fdN" };
476
- string expectedMessage = " Invalid optimizer step sequence in --yul-optimizations: Too many cleanup sequence delimiters" ;
477
- auto hasCorrectMessage = [&](CommandLineValidationError const & _exception) { return _exception.what () == expectedMessage; };
478
- BOOST_CHECK_EXCEPTION (parseCommandLine (commandLine), CommandLineValidationError, hasCorrectMessage);
491
+ vector<string> const expectedErrorMessages {
492
+ " 'b' is not a valid step abbreviation" ,
493
+ " Brackets nested too deep" ,
494
+ " Unbalanced brackets" ,
495
+ " Unbalanced brackets" ,
496
+ " Cleanup sequence delimiter cannot be placed inside the brackets" ,
497
+ " Too many cleanup sequence delimiters"
498
+ };
499
+
500
+ BOOST_CHECK_EQUAL (invalidSequenceInputs.size (), expectedErrorMessages.size ());
501
+
502
+ string const baseExpectedErrorMessage = " Invalid optimizer step sequence in --yul-optimizations: " ;
503
+
504
+ for (size_t i = 0 ; i < invalidSequenceInputs.size (); ++i)
505
+ {
506
+ vector<string> const commandLineOptions = {" solc" , " contract.sol" , " --optimize" , " --yul-optimizations=" + invalidSequenceInputs[i]};
507
+ string const expectedErrorMessage = baseExpectedErrorMessage + expectedErrorMessages[i];
508
+ auto hasCorrectMessage = [&](CommandLineValidationError const & _exception) { return _exception.what () == expectedErrorMessage; };
509
+ BOOST_CHECK_EXCEPTION (parseCommandLine (commandLineOptions), CommandLineValidationError, hasCorrectMessage);
510
+ }
479
511
}
480
512
481
513
BOOST_AUTO_TEST_SUITE_END ()
0 commit comments