block-multi.fmt.sol 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // config: single_line_statement_blocks = "multi"
  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) {
  15. execute();
  16. }
  17. bool condition;
  18. bool anotherLongCondition;
  19. bool andAnotherVeryVeryLongCondition;
  20. if (
  21. condition && anotherLongCondition || andAnotherVeryVeryLongCondition
  22. ) {
  23. execute();
  24. }
  25. // comment
  26. if (condition) {
  27. execute();
  28. } else if (anotherLongCondition) {
  29. execute(); // differently
  30. }
  31. /* comment1 */
  32. if ( /* comment2 */ /* comment3 */
  33. condition // comment4
  34. ) {
  35. // comment5
  36. execute();
  37. } // comment6
  38. if (condition) {
  39. execute();
  40. } // comment7
  41. /* comment8 */
  42. /* comment9 */
  43. else if ( /* comment10 */
  44. anotherLongCondition // comment11
  45. ) {
  46. /* comment12 */
  47. execute();
  48. } // comment13
  49. /* comment14 */
  50. else {} // comment15
  51. if (
  52. // comment16
  53. condition /* comment17 */
  54. ) {
  55. execute();
  56. }
  57. if (condition) {
  58. execute();
  59. } else {
  60. executeElse();
  61. }
  62. if (condition) {
  63. if (anotherLongCondition) {
  64. execute();
  65. }
  66. }
  67. if (condition) {
  68. execute();
  69. }
  70. if (
  71. condition && anotherLongCondition || andAnotherVeryVeryLongCondition
  72. ) {
  73. execute();
  74. }
  75. if (condition) {
  76. if (anotherLongCondition) {
  77. execute();
  78. }
  79. }
  80. if (condition) {
  81. execute();
  82. } // comment18
  83. if (condition) {
  84. executeWithMultipleParameters(condition, anotherLongCondition);
  85. }
  86. if (condition) {
  87. executeWithVeryVeryVeryLongNameAndSomeParameter(condition);
  88. }
  89. if (condition) {
  90. execute();
  91. } else {
  92. execute();
  93. }
  94. if (condition) {}
  95. if (condition) {
  96. executeWithMultipleParameters(condition, anotherLongCondition);
  97. } else if (anotherLongCondition) {
  98. execute();
  99. }
  100. if (condition && ((condition || anotherLongCondition))) {
  101. execute();
  102. }
  103. // if statement
  104. if (condition) {
  105. execute();
  106. }
  107. // else statement
  108. else {
  109. execute();
  110. }
  111. // if statement
  112. if (condition) {
  113. execute();
  114. }
  115. // else statement
  116. else {
  117. executeWithMultipleParameters(
  118. anotherLongCondition, andAnotherVeryVeryLongCondition
  119. );
  120. }
  121. if (condition) {
  122. execute();
  123. } else if (condition) {
  124. execute();
  125. } else if (condition) {
  126. execute();
  127. } else if (condition) {
  128. execute();
  129. } else if (condition) {
  130. execute();
  131. }
  132. if (condition) {
  133. execute();
  134. } else if (condition) {
  135. execute();
  136. } else if (condition) {
  137. execute();
  138. } else if (condition) {
  139. execute();
  140. } else if (condition) {
  141. execute();
  142. } else {
  143. executeElse();
  144. }
  145. }
  146. }