| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491 |
- pragma solidity ^0.5.2;
- // forgefmt: disable-next-line
- pragma solidity ^0.5.2;
- import {
- symbol1 as alias1,
- symbol2 as alias2,
- symbol3 as alias3,
- symbol4
- } from "File2.sol";
- // forgefmt: disable-next-line
- import {symbol1 as alias1, symbol2 as alias2, symbol3 as alias3, symbol4} from 'File2.sol';
- enum States {
- State1,
- State2,
- State3,
- State4,
- State5,
- State6,
- State7,
- State8,
- State9
- }
- // forgefmt: disable-next-line
- enum States { State1, State2, State3, State4, State5, State6, State7, State8, State9 }
- // forgefmt: disable-next-line
- bytes32 constant private BYTES = 0x035aff83d86937d35b32e04f0ddc6ff469290eef2f1b692d8a815c89404d4749;
- // forgefmt: disable-start
- // comment1
- // comment2
- /* comment 3 */ /*
- comment4
- */ // comment 5
- /// Doccomment 1
- /// Doccomment 2
- /**
- * docccoment 3
- */
- // forgefmt: disable-end
- // forgefmt: disable-start
- function test1() {}
- function test2() {}
- // forgefmt: disable-end
- contract Constructors is Ownable, Changeable {
- //forgefmt: disable-next-item
- function Constructors(variable1) public Changeable(variable1) Ownable() onlyOwner {
- }
- //forgefmt: disable-next-item
- constructor(variable1, variable2, variable3, variable4, variable5, variable6, variable7) public Changeable(variable1, variable2, variable3, variable4, variable5, variable6, variable7) Ownable() onlyOwner {}
- }
- function test() {
- uint256 pi_approx = 666 / 212;
- uint256 pi_approx = /* forgefmt: disable-start */ 666 / 212; /* forgefmt: disable-end */
- // forgefmt: disable-next-item
- uint256 pi_approx = 666 /
- 212;
- uint256 test_postfix = 1; // forgefmt: disable-start
- // comment1
- // comment2
- // comment3
- // forgefmt: disable-end
- }
- // forgefmt: disable-next-item
- function testFunc(uint256 num, bytes32 data , address receiver)
- public payable attr1 Cool( "hello" ) {}
- function testAttrs(uint256 num, bytes32 data, address receiver)
- // forgefmt: disable-next-line
- public payable attr1 Cool( "hello" )
- {}
- // forgefmt: disable-next-line
- function testParams(uint256 num, bytes32 data , address receiver)
- public
- payable
- attr1
- Cool("hello")
- {}
- function testDoWhile() external {
- //forgefmt: disable-start
- uint256 i;
- do { "test"; } while (i != 0);
- do
- {}
- while
- (
- i != 0);
- bool someVeryVeryLongCondition;
- do { "test"; } while(
- someVeryVeryLongCondition && !someVeryVeryLongCondition &&
- !someVeryVeryLongCondition &&
- someVeryVeryLongCondition);
- do i++; while(i < 10);
- do do i++; while (i < 30); while(i < 20);
- //forgefmt: disable-end
- }
- function forStatement() {
- //forgefmt: disable-start
- for
- (uint256 i1
- ; i1 < 10; i1++)
- {
- i1++;
- }
- uint256 i2;
- for(++i2;i2<10;i2++)
-
- {}
- uint256 veryLongVariableName = 1000;
- for ( uint256 i3; i3 < 10
- && veryLongVariableName>999 && veryLongVariableName< 1001
- ; i3++)
- { i3 ++ ; }
- for (type(uint256).min;;) {}
- for (;;) { "test" ; }
- for (uint256 i4; i4< 10; i4++) i4++;
- for (uint256 i5; ;)
- for (uint256 i6 = 10; i6 > i5; i6--)
- i5++;
- //forgefmt: disable-end
- }
- function callArgTest() {
- //forgefmt: disable-start
- target.run{ gas: gasleft(), value: 1 wei };
- target.run{gas:1,value:0x00}();
- target.run{
- gas : 1000,
- value: 1 ether
- } ();
- target.run{ gas: estimate(),
- value: value(1) }();
- target.run { value:
- value(1 ether), gas: veryAndVeryLongNameOfSomeGasEstimateFunction() } ();
- target.run /* comment 1 */ { value: /* comment2 */ 1 };
- target.run { /* comment3 */ value: 1, // comment4
- gas: gasleft()};
- target.run {
- // comment5
- value: 1,
- // comment6
- gas: gasleft()};
- //forgefmt: disable-end
- }
- function ifTest() {
- // forgefmt: disable-start
- if (condition)
- execute();
- else
- executeElse();
- // forgefmt: disable-end
- /* forgefmt: disable-next-line */
- if (condition && anotherLongCondition ) {
- execute();
- }
- }
- function yulTest() {
- // forgefmt: disable-start
- assembly {
- let payloadSize := sub(calldatasize(), 4)
- calldatacopy(0, 4, payloadSize)
- mstore(payloadSize, shl(96, caller()))
- let result :=
- delegatecall(gas(), moduleImpl, 0, add(payloadSize, 20), 0, 0)
- returndatacopy(0, 0, returndatasize())
- switch result
- case 0 { revert(0, returndatasize()) }
- default { return(0, returndatasize()) }
- }
- // forgefmt: disable-end
- }
- function literalTest() {
- // forgefmt: disable-start
- true;
- 0x123_456;
- .1;
- "foobar";
- hex"001122FF";
- 0xc02aaa39b223Fe8D0A0e5C4F27ead9083c756Cc2;
- // forgefmt: disable-end
- // forgefmt: disable-next-line
- bytes memory bytecode = hex"ff";
- }
- function returnTest() {
- // forgefmt: disable-start
- if (val == 0) {
- return // return single 1
- 0x00;
- }
- if (val == 1) { return
- 1; }
- if (val == 2) {
- return 3
- -
- 1;
- }
- if (val == 4) {
- /* return single 2 */ return 2** // return single 3
- 3 // return single 4
- ;
- }
- return value(); // return single 5
- return ;
- return /* return mul 4 */
- (
- 987654321, 1234567890,/* return mul 5 */ false);
- // forgefmt: disable-end
- }
- function namedFuncCall() {
- // forgefmt: disable-start
- SimpleStruct memory simple = SimpleStruct({ val: 0 });
- ComplexStruct memory complex = ComplexStruct({ val: 1, anotherVal: 2, flag: true, timestamp: block.timestamp });
- StructWithAVeryLongNameThatExceedsMaximumLengthThatIsAllowedForFormatting memory long = StructWithAVeryLongNameThatExceedsMaximumLengthThatIsAllowedForFormatting({ whyNameSoLong: "dunno" });
-
- SimpleStruct memory simple2 = SimpleStruct(
- { // comment1
- /* comment2 */ val : /* comment3 */ 0
-
- }
- );
- // forgefmt: disable-end
- }
- function revertTest() {
- // forgefmt: disable-start
- revert ({ });
- revert EmptyError({});
- revert SimpleError({ val: 0 });
- revert ComplexError(
- {
- val: 0,
- ts: block.timestamp,
- message: "some reason"
- });
-
- revert SomeVeryVeryVeryLongErrorNameWithNamedArgumentsThatExceedsMaximumLength({ val: 0, ts: 0x00, message: "something unpredictable happened that caused execution to revert"});
- revert // comment1
- ({});
- // forgefmt: disable-end
- }
- function testTernary() {
- // forgefmt: disable-start
- bool condition;
- bool someVeryVeryLongConditionUsedInTheTernaryExpression;
- condition ? 0 : 1;
- someVeryVeryLongConditionUsedInTheTernaryExpression ? 1234567890 : 987654321;
- condition /* comment1 */ ? /* comment2 */ 1001 /* comment3 */ : /* comment4 */ 2002;
- // comment5
- someVeryVeryLongConditionUsedInTheTernaryExpression ? 1
- // comment6
- :
- // comment7
- 0; // comment8
- // forgefmt: disable-end
- }
- function thisTest() {
- // forgefmt: disable-start
- this.someFunc();
- this.someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword();
- this // comment1
- .someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword();
- address(this).balance;
-
- address thisAddress = address(
- // comment2
- /* comment3 */ this // comment 4
- );
- // forgefmt: disable-end
- }
- function tryTest() {
- // forgefmt: disable-start
- try unknown.empty() {} catch {}
- try unknown.lookup() returns (uint256) {} catch Error(string memory) {}
- try unknown.lookup() returns (uint256) {} catch Error(string memory) {} catch (bytes memory) {}
- try unknown
- .lookup() returns (uint256
- ) {
- } catch ( bytes memory ){}
- try unknown.empty() {
- unknown.doSomething();
- } catch {
- unknown.handleError();
- }
- try unknown.empty() {
- unknown.doSomething();
- } catch Error(string memory) {}
- catch Panic(uint) {}
- catch {
- unknown.handleError();
- }
- try unknown.lookupMultipleValues() returns (uint256, uint256, uint256, uint256, uint256) {} catch Error(string memory) {} catch {}
-
- try unknown.lookupMultipleValues() returns (uint256, uint256, uint256, uint256, uint256) {
- unknown.doSomething();
- }
- catch Error(string memory) {
- unknown.handleError();
- }
- catch {}
- // forgefmt: disable-end
- }
- function testArray() {
- // forgefmt: disable-start
- msg.data[
- // comment1
- 4:];
- msg.data[
- : /* comment2 */ msg.data.length // comment3
- ];
- msg.data[
- // comment4
- 4 // comment5
- :msg.data.length /* comment6 */];
- // forgefmt: disable-end
- }
- function testUnit() {
- // forgefmt: disable-start
- uint256 timestamp;
- timestamp = 1 seconds;
- timestamp = 1 minutes;
- timestamp = 1 hours;
- timestamp = 1 days;
- timestamp = 1 weeks;
- uint256 value;
- value = 1 wei;
- value = 1 gwei;
- value = 1 ether;
- uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue;
- value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2
- value = 1 // comment3
- // comment4
- ether; // comment5
- // forgefmt: disable-end
- }
- contract UsingExampleContract {
- // forgefmt: disable-start
- using UsingExampleLibrary for * ;
- using UsingExampleLibrary for uint;
- using Example.UsingExampleLibrary for uint;
- using { M.g, M.f} for uint;
- using UsingExampleLibrary for uint global;
- using { These, Are, MultipleLibraries, ThatNeedToBePut, OnSeparateLines } for uint;
- using { This.isareally.longmember.access.expression.that.needs.to.besplit.into.lines } for uint;
- // forgefmt: disable-end
- }
- function testAssignment() {
- // forgefmt: disable-start
- (, uint256 second) = (1, 2);
- (uint256 listItem001) = 1;
- (uint256 listItem002, uint256 listItem003) = (10, 20);
- (uint256 listItem004, uint256 listItem005, uint256 listItem006) =
- (10, 20, 30);
- // forgefmt: disable-end
- }
- function testWhile() {
- // forgefmt: disable-start
- uint256 i1;
- while ( i1 < 10 ) {
- i1++;
- }
- while (i1<10) i1++;
- while (i1<10)
- while (i1<10)
- i1++;
- uint256 i2;
- while ( i2 < 10) { i2++; }
- uint256 i3; while (
- i3 < 10
- ) { i3++; }
- uint256 i4; while (i4 < 10)
- { i4 ++ ;}
- uint256 someLongVariableName;
- while (
- someLongVariableName < 10 && someLongVariableName < 11 && someLongVariableName < 12
- ) { someLongVariableName ++; } someLongVariableName++;
- // forgefmt: disable-end
- }
- function testLine() {}
- function /* forgefmt: disable-line */ testLine( ) { }
- function testLine() {}
- function testLine( ) { } // forgefmt: disable-line
- // forgefmt: disable-start
- type Hello is uint256;
- error
- TopLevelCustomError();
- error TopLevelCustomErrorWithArg(uint x) ;
- error TopLevelCustomErrorArgWithoutName (string);
- event Event1(uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a);
- // forgefmt: disable-stop
|