fmt.sol 3.3 KB

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