block-single.fmt.sol 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // config: single_line_statement_blocks = "single"
  2. function execute() returns (bool) {
  3. if (true) {
  4. // always returns true
  5. return true;
  6. }
  7. return false;
  8. }
  9. function executeElse() {}
  10. function executeWithMultipleParameters(bool parameter1, bool parameter2) {}
  11. function executeWithVeryVeryVeryLongNameAndSomeParameter(bool parameter) {}
  12. contract IfStatement {
  13. function test() external {
  14. if (true) execute();
  15. bool condition;
  16. bool anotherLongCondition;
  17. bool andAnotherVeryVeryLongCondition;
  18. if (
  19. condition && anotherLongCondition || andAnotherVeryVeryLongCondition
  20. ) execute();
  21. // comment
  22. if (condition) execute();
  23. else if (anotherLongCondition) execute(); // differently
  24. /* comment1 */
  25. if ( /* comment2 */ /* comment3 */
  26. condition // comment4
  27. ) {
  28. // comment5
  29. execute();
  30. } // comment6
  31. if (condition) {
  32. execute();
  33. } // comment7
  34. /* comment8 */
  35. /* comment9 */
  36. else if ( /* comment10 */
  37. anotherLongCondition // comment11
  38. ) {
  39. /* comment12 */
  40. execute();
  41. } // comment13
  42. /* comment14 */
  43. else {} // comment15
  44. if (
  45. // comment16
  46. condition /* comment17 */
  47. ) execute();
  48. if (condition) execute();
  49. else executeElse();
  50. if (condition) if (anotherLongCondition) execute();
  51. if (condition) execute();
  52. if (
  53. condition && anotherLongCondition || andAnotherVeryVeryLongCondition
  54. ) execute();
  55. if (condition) if (anotherLongCondition) execute();
  56. if (condition) execute(); // comment18
  57. if (condition) {
  58. executeWithMultipleParameters(condition, anotherLongCondition);
  59. }
  60. if (condition) {
  61. executeWithVeryVeryVeryLongNameAndSomeParameter(condition);
  62. }
  63. if (condition) execute();
  64. else execute();
  65. if (condition) {}
  66. if (condition) {
  67. executeWithMultipleParameters(condition, anotherLongCondition);
  68. } else if (anotherLongCondition) {
  69. execute();
  70. }
  71. if (condition && ((condition || anotherLongCondition))) execute();
  72. // if statement
  73. if (condition) execute();
  74. // else statement
  75. else execute();
  76. // if statement
  77. if (condition) {
  78. execute();
  79. }
  80. // else statement
  81. else {
  82. executeWithMultipleParameters(
  83. anotherLongCondition, andAnotherVeryVeryLongCondition
  84. );
  85. }
  86. if (condition) execute();
  87. else if (condition) execute();
  88. else if (condition) execute();
  89. else if (condition) execute();
  90. else if (condition) execute();
  91. if (condition) execute();
  92. else if (condition) execute();
  93. else if (condition) execute();
  94. else if (condition) execute();
  95. else if (condition) execute();
  96. else executeElse();
  97. }
  98. }