|
| 1 | +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing |
| 2 | + |
| 3 | +exports[`ModifierInvocations.sol - {"compiler":"0.4.26"} format 1`] = ` |
| 4 | +====================================options===================================== |
| 5 | +compiler: "0.4.26" |
| 6 | +parsers: ["slang"] |
| 7 | +printWidth: 80 |
| 8 | + | printWidth |
| 9 | +=====================================input====================================== |
| 10 | +// SPDX-License-Identifier: MIT |
| 11 | +pragma solidity 0.4.26; |
| 12 | +
|
| 13 | +contract ModifierDefinitions { |
| 14 | + // We enforce the use of parentheses in modifiers without parameters. |
| 15 | + modifier emptyParams {_;} |
| 16 | + modifier noParams() {_;} |
| 17 | +} |
| 18 | +
|
| 19 | +contract ModifierInvocations is ModifierDefinitions { |
| 20 | + // We can't differentiate between constructor calls or modifiers, so we keep |
| 21 | + // parentheses untouched in constructors. |
| 22 | + function ModifierInvocations () emptyParams noParams() ModifierDefinitions() {} |
| 23 | +
|
| 24 | + // We remove parentheses in modifiers without arguments. |
| 25 | + function test() public emptyParams noParams() {} |
| 26 | +} |
| 27 | +
|
| 28 | +library ModifierInvocationsLibrary { |
| 29 | + // We enforce the use of parentheses in modifiers without parameters. |
| 30 | + modifier emptyParams {_;} |
| 31 | + modifier noParams() {_;} |
| 32 | +
|
| 33 | + modifier nonZero (uint x) { |
| 34 | + require (x != 0); |
| 35 | + _; |
| 36 | + } |
| 37 | +
|
| 38 | + function isPrime (uint x) public nonZero (x) returns (bool) { |
| 39 | + // Complicated logic here |
| 40 | + } |
| 41 | +
|
| 42 | + // We remove parentheses in modifiers without arguments. |
| 43 | + function test() public emptyParams noParams() {} |
| 44 | +} |
| 45 | +
|
| 46 | +=====================================output===================================== |
| 47 | +// SPDX-License-Identifier: MIT |
| 48 | +pragma solidity 0.4.26; |
| 49 | +
|
| 50 | +contract ModifierDefinitions { |
| 51 | + // We enforce the use of parentheses in modifiers without parameters. |
| 52 | + modifier emptyParams() { |
| 53 | + _; |
| 54 | + } |
| 55 | + modifier noParams() { |
| 56 | + _; |
| 57 | + } |
| 58 | +} |
| 59 | +
|
| 60 | +contract ModifierInvocations is ModifierDefinitions { |
| 61 | + // We can't differentiate between constructor calls or modifiers, so we keep |
| 62 | + // parentheses untouched in constructors. |
| 63 | + function ModifierInvocations() |
| 64 | + emptyParams |
| 65 | + noParams() |
| 66 | + ModifierDefinitions() |
| 67 | + {} |
| 68 | +
|
| 69 | + // We remove parentheses in modifiers without arguments. |
| 70 | + function test() public emptyParams noParams {} |
| 71 | +} |
| 72 | +
|
| 73 | +library ModifierInvocationsLibrary { |
| 74 | + // We enforce the use of parentheses in modifiers without parameters. |
| 75 | + modifier emptyParams() { |
| 76 | + _; |
| 77 | + } |
| 78 | + modifier noParams() { |
| 79 | + _; |
| 80 | + } |
| 81 | +
|
| 82 | + modifier nonZero(uint x) { |
| 83 | + require(x != 0); |
| 84 | + _; |
| 85 | + } |
| 86 | +
|
| 87 | + function isPrime(uint x) public nonZero(x) returns (bool) { |
| 88 | + // Complicated logic here |
| 89 | + } |
| 90 | +
|
| 91 | + // We remove parentheses in modifiers without arguments. |
| 92 | + function test() public emptyParams noParams {} |
| 93 | +} |
| 94 | +
|
| 95 | +================================================================================ |
| 96 | +`; |
0 commit comments