prettier-plugin-solidity 1.0.0-beta.15 β 1.0.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/CI.yml +6 -6
- package/README.md +64 -3
- package/package.json +16 -12
- package/src/nodes/FunctionCall.js +26 -23
- package/src/nodes/IndexAccess.js +29 -7
- package/src/nodes/MemberAccess.js +63 -26
- package/src/nodes/ModifierDefinition.js +14 -16
- package/src/nodes/ModifierInvocation.js +2 -0
- package/src/nodes/StringLiteral.js +2 -2
- package/src/nodes/TypeDefinition.js +5 -0
- package/src/nodes/VariableDeclarationStatement.js +21 -8
- package/src/nodes/index.js +1 -0
- package/src/nodes/print-separated-list.js +1 -6
- package/src/parser.js +15 -9
- package/tests/config/format-test.js +1 -0
- package/tests/format/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap +1 -1
- package/tests/format/ExplicitVariableTypes/ExplicitVariableTypes.sol +1 -1
- package/tests/format/ExplicitVariableTypes/__snapshots__/jsfmt.spec.js.snap +6 -6
- package/tests/format/FunctionCalls/__snapshots__/jsfmt.spec.js.snap +98 -86
- package/tests/format/FunctionDefinitions/FunctionDefinitions.sol +2 -2
- package/tests/format/FunctionDefinitions/__snapshots__/jsfmt.spec.js.snap +2 -2
- package/tests/format/HexLiteral/HexLiteral.sol +1 -1
- package/tests/format/HexLiteral/__snapshots__/jsfmt.spec.js.snap +4 -4
- package/tests/format/Issues/Issue564.sol +9 -0
- package/tests/format/Issues/__snapshots__/jsfmt.spec.js.snap +37 -5
- package/tests/format/MemberAccess/MemberAccess.sol +46 -0
- package/tests/format/MemberAccess/__snapshots__/jsfmt.spec.js.snap +99 -0
- package/tests/format/ModifierInvocations/ModifierInvocations.sol +17 -0
- package/tests/format/ModifierInvocations/__snapshots__/jsfmt.spec.js.snap +51 -0
- package/tests/format/ModifierInvocations/jsfmt.spec.js +1 -0
- package/tests/format/MultipartStrings/__snapshots__/jsfmt.spec.js.snap +3 -1
- package/tests/format/Parentheses/AddNoParentheses.sol +1 -1
- package/tests/format/Parentheses/BitAndNoParentheses.sol +1 -1
- package/tests/format/Parentheses/BitOrNoParentheses.sol +1 -1
- package/tests/format/Parentheses/BitXorNoParentheses.sol +1 -1
- package/tests/format/Parentheses/DivNoParentheses.sol +1 -1
- package/tests/format/Parentheses/ExpNoParentheses.sol +1 -1
- package/tests/format/Parentheses/LogicNoParentheses.sol +1 -1
- package/tests/format/Parentheses/ModNoParentheses.sol +1 -1
- package/tests/format/Parentheses/MulNoParentheses.sol +1 -1
- package/tests/format/Parentheses/ShiftLNoParentheses.sol +1 -1
- package/tests/format/Parentheses/ShiftRNoParentheses.sol +1 -1
- package/tests/format/Parentheses/SubNoParentheses.sol +1 -1
- package/tests/format/Parentheses/__snapshots__/jsfmt.spec.js.snap +24 -24
- package/tests/format/Pragma/Pragma.sol +1 -0
- package/tests/format/Pragma/__snapshots__/jsfmt.spec.js.snap +2 -0
- package/tests/format/SplittableCommodity/__snapshots__/jsfmt.spec.js.snap +1 -1
- package/tests/format/StringLiteral/StringLiteral.sol +11 -0
- package/tests/format/StringLiteral/__snapshots__/jsfmt.spec.js.snap +36 -0
- package/tests/format/StringLiteral/jsfmt.spec.js +1 -0
- package/tests/format/TypeDefinition/TypeDefinition.sol +12 -0
- package/tests/format/TypeDefinition/__snapshots__/jsfmt.spec.js.snap +74 -0
- package/tests/format/TypeDefinition/jsfmt.spec.js +1 -0
- package/tests/format/quotes/__snapshots__/jsfmt.spec.js.snap +18 -6
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ModifierInvocations.sol format 1`] = `
|
|
4
|
+
====================================options=====================================
|
|
5
|
+
parsers: ["solidity-parse"]
|
|
6
|
+
printWidth: 80
|
|
7
|
+
| printWidth
|
|
8
|
+
=====================================input======================================
|
|
9
|
+
// SPDX-License-Identifier: MIT
|
|
10
|
+
pragma solidity 0.8.10;
|
|
11
|
+
|
|
12
|
+
contract ModifierDefinitions {
|
|
13
|
+
// We enforce the use of parentheses in modifiers without parameters.
|
|
14
|
+
modifier emptyParams {_;}
|
|
15
|
+
modifier noParams() {_;}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
contract ModifierInvocations is ModifierDefinitions {
|
|
19
|
+
// We can't differentiate between constructor calls or modifiers, so we keep
|
|
20
|
+
// parentheses untouched in constructors.
|
|
21
|
+
constructor () emptyParams noParams() ModifierDefinitions() {}
|
|
22
|
+
|
|
23
|
+
// We remove parentheses in modifiers without arguments.
|
|
24
|
+
function test() public emptyParams noParams() {}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
=====================================output=====================================
|
|
28
|
+
// SPDX-License-Identifier: MIT
|
|
29
|
+
pragma solidity 0.8.10;
|
|
30
|
+
|
|
31
|
+
contract ModifierDefinitions {
|
|
32
|
+
// We enforce the use of parentheses in modifiers without parameters.
|
|
33
|
+
modifier emptyParams() {
|
|
34
|
+
_;
|
|
35
|
+
}
|
|
36
|
+
modifier noParams() {
|
|
37
|
+
_;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
contract ModifierInvocations is ModifierDefinitions {
|
|
42
|
+
// We can't differentiate between constructor calls or modifiers, so we keep
|
|
43
|
+
// parentheses untouched in constructors.
|
|
44
|
+
constructor() emptyParams noParams() ModifierDefinitions() {}
|
|
45
|
+
|
|
46
|
+
// We remove parentheses in modifiers without arguments.
|
|
47
|
+
function test() public emptyParams noParams {}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
================================================================================
|
|
51
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
run_spec(__dirname, ['solidity-parse']);
|
|
@@ -8,7 +8,7 @@ printWidth: 80
|
|
|
8
8
|
| printWidth
|
|
9
9
|
=====================================input======================================
|
|
10
10
|
// SPDX-License-Identifier: MIT
|
|
11
|
-
pragma solidity 0.8.
|
|
11
|
+
pragma solidity 0.8.10;
|
|
12
12
|
|
|
13
13
|
contract AddNoParentheses {
|
|
14
14
|
function addAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -102,7 +102,7 @@ contract AddNoParentheses {
|
|
|
102
102
|
|
|
103
103
|
=====================================output=====================================
|
|
104
104
|
// SPDX-License-Identifier: MIT
|
|
105
|
-
pragma solidity 0.8.
|
|
105
|
+
pragma solidity 0.8.10;
|
|
106
106
|
|
|
107
107
|
contract AddNoParentheses {
|
|
108
108
|
function addAdd(
|
|
@@ -205,7 +205,7 @@ printWidth: 80
|
|
|
205
205
|
| printWidth
|
|
206
206
|
=====================================input======================================
|
|
207
207
|
// SPDX-License-Identifier: MIT
|
|
208
|
-
pragma solidity 0.8.
|
|
208
|
+
pragma solidity 0.8.10;
|
|
209
209
|
|
|
210
210
|
contract BitAndNoParentheses {
|
|
211
211
|
function bitAndAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -299,7 +299,7 @@ contract BitAndNoParentheses {
|
|
|
299
299
|
|
|
300
300
|
=====================================output=====================================
|
|
301
301
|
// SPDX-License-Identifier: MIT
|
|
302
|
-
pragma solidity 0.8.
|
|
302
|
+
pragma solidity 0.8.10;
|
|
303
303
|
|
|
304
304
|
contract BitAndNoParentheses {
|
|
305
305
|
function bitAndAdd(
|
|
@@ -402,7 +402,7 @@ printWidth: 80
|
|
|
402
402
|
| printWidth
|
|
403
403
|
=====================================input======================================
|
|
404
404
|
// SPDX-License-Identifier: MIT
|
|
405
|
-
pragma solidity 0.8.
|
|
405
|
+
pragma solidity 0.8.10;
|
|
406
406
|
|
|
407
407
|
contract BitOrNoParentheses {
|
|
408
408
|
function bitOrAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -496,7 +496,7 @@ contract BitOrNoParentheses {
|
|
|
496
496
|
|
|
497
497
|
=====================================output=====================================
|
|
498
498
|
// SPDX-License-Identifier: MIT
|
|
499
|
-
pragma solidity 0.8.
|
|
499
|
+
pragma solidity 0.8.10;
|
|
500
500
|
|
|
501
501
|
contract BitOrNoParentheses {
|
|
502
502
|
function bitOrAdd(
|
|
@@ -599,7 +599,7 @@ printWidth: 80
|
|
|
599
599
|
| printWidth
|
|
600
600
|
=====================================input======================================
|
|
601
601
|
// SPDX-License-Identifier: MIT
|
|
602
|
-
pragma solidity 0.8.
|
|
602
|
+
pragma solidity 0.8.10;
|
|
603
603
|
|
|
604
604
|
contract BitXorNoParentheses {
|
|
605
605
|
function bitXorAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -693,7 +693,7 @@ contract BitXorNoParentheses {
|
|
|
693
693
|
|
|
694
694
|
=====================================output=====================================
|
|
695
695
|
// SPDX-License-Identifier: MIT
|
|
696
|
-
pragma solidity 0.8.
|
|
696
|
+
pragma solidity 0.8.10;
|
|
697
697
|
|
|
698
698
|
contract BitXorNoParentheses {
|
|
699
699
|
function bitXorAdd(
|
|
@@ -796,7 +796,7 @@ printWidth: 80
|
|
|
796
796
|
| printWidth
|
|
797
797
|
=====================================input======================================
|
|
798
798
|
// SPDX-License-Identifier: MIT
|
|
799
|
-
pragma solidity 0.8.
|
|
799
|
+
pragma solidity 0.8.10;
|
|
800
800
|
|
|
801
801
|
contract DivNoParentheses {
|
|
802
802
|
function divAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -890,7 +890,7 @@ contract DivNoParentheses {
|
|
|
890
890
|
|
|
891
891
|
=====================================output=====================================
|
|
892
892
|
// SPDX-License-Identifier: MIT
|
|
893
|
-
pragma solidity 0.8.
|
|
893
|
+
pragma solidity 0.8.10;
|
|
894
894
|
|
|
895
895
|
contract DivNoParentheses {
|
|
896
896
|
function divAdd(
|
|
@@ -993,7 +993,7 @@ printWidth: 80
|
|
|
993
993
|
| printWidth
|
|
994
994
|
=====================================input======================================
|
|
995
995
|
// SPDX-License-Identifier: MIT
|
|
996
|
-
pragma solidity 0.8.
|
|
996
|
+
pragma solidity 0.8.10;
|
|
997
997
|
|
|
998
998
|
contract ExpNoParentheses {
|
|
999
999
|
function expAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -1087,7 +1087,7 @@ contract ExpNoParentheses {
|
|
|
1087
1087
|
|
|
1088
1088
|
=====================================output=====================================
|
|
1089
1089
|
// SPDX-License-Identifier: MIT
|
|
1090
|
-
pragma solidity 0.8.
|
|
1090
|
+
pragma solidity 0.8.10;
|
|
1091
1091
|
|
|
1092
1092
|
contract ExpNoParentheses {
|
|
1093
1093
|
function expAdd(
|
|
@@ -1190,7 +1190,7 @@ printWidth: 80
|
|
|
1190
1190
|
| printWidth
|
|
1191
1191
|
=====================================input======================================
|
|
1192
1192
|
// SPDX-License-Identifier: MIT
|
|
1193
|
-
pragma solidity 0.8.
|
|
1193
|
+
pragma solidity 0.8.10;
|
|
1194
1194
|
|
|
1195
1195
|
contract LogicNoParentheses {
|
|
1196
1196
|
function orOr(bool a, bool b, bool c) public pure returns (bool) {
|
|
@@ -1212,7 +1212,7 @@ contract LogicNoParentheses {
|
|
|
1212
1212
|
|
|
1213
1213
|
=====================================output=====================================
|
|
1214
1214
|
// SPDX-License-Identifier: MIT
|
|
1215
|
-
pragma solidity 0.8.
|
|
1215
|
+
pragma solidity 0.8.10;
|
|
1216
1216
|
|
|
1217
1217
|
contract LogicNoParentheses {
|
|
1218
1218
|
function orOr(
|
|
@@ -1259,7 +1259,7 @@ printWidth: 80
|
|
|
1259
1259
|
| printWidth
|
|
1260
1260
|
=====================================input======================================
|
|
1261
1261
|
// SPDX-License-Identifier: MIT
|
|
1262
|
-
pragma solidity 0.8.
|
|
1262
|
+
pragma solidity 0.8.10;
|
|
1263
1263
|
|
|
1264
1264
|
contract ModNoParentheses {
|
|
1265
1265
|
function modAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -1353,7 +1353,7 @@ contract ModNoParentheses {
|
|
|
1353
1353
|
|
|
1354
1354
|
=====================================output=====================================
|
|
1355
1355
|
// SPDX-License-Identifier: MIT
|
|
1356
|
-
pragma solidity 0.8.
|
|
1356
|
+
pragma solidity 0.8.10;
|
|
1357
1357
|
|
|
1358
1358
|
contract ModNoParentheses {
|
|
1359
1359
|
function modAdd(
|
|
@@ -1456,7 +1456,7 @@ printWidth: 80
|
|
|
1456
1456
|
| printWidth
|
|
1457
1457
|
=====================================input======================================
|
|
1458
1458
|
// SPDX-License-Identifier: MIT
|
|
1459
|
-
pragma solidity 0.8.
|
|
1459
|
+
pragma solidity 0.8.10;
|
|
1460
1460
|
|
|
1461
1461
|
contract MulNoParentheses {
|
|
1462
1462
|
function mulAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -1550,7 +1550,7 @@ contract MulNoParentheses {
|
|
|
1550
1550
|
|
|
1551
1551
|
=====================================output=====================================
|
|
1552
1552
|
// SPDX-License-Identifier: MIT
|
|
1553
|
-
pragma solidity 0.8.
|
|
1553
|
+
pragma solidity 0.8.10;
|
|
1554
1554
|
|
|
1555
1555
|
contract MulNoParentheses {
|
|
1556
1556
|
function mulAdd(
|
|
@@ -1653,7 +1653,7 @@ printWidth: 80
|
|
|
1653
1653
|
| printWidth
|
|
1654
1654
|
=====================================input======================================
|
|
1655
1655
|
// SPDX-License-Identifier: MIT
|
|
1656
|
-
pragma solidity 0.8.
|
|
1656
|
+
pragma solidity 0.8.10;
|
|
1657
1657
|
|
|
1658
1658
|
contract ShiftLNoParentheses {
|
|
1659
1659
|
function shiftLAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -1747,7 +1747,7 @@ contract ShiftLNoParentheses {
|
|
|
1747
1747
|
|
|
1748
1748
|
=====================================output=====================================
|
|
1749
1749
|
// SPDX-License-Identifier: MIT
|
|
1750
|
-
pragma solidity 0.8.
|
|
1750
|
+
pragma solidity 0.8.10;
|
|
1751
1751
|
|
|
1752
1752
|
contract ShiftLNoParentheses {
|
|
1753
1753
|
function shiftLAdd(
|
|
@@ -1850,7 +1850,7 @@ printWidth: 80
|
|
|
1850
1850
|
| printWidth
|
|
1851
1851
|
=====================================input======================================
|
|
1852
1852
|
// SPDX-License-Identifier: MIT
|
|
1853
|
-
pragma solidity 0.8.
|
|
1853
|
+
pragma solidity 0.8.10;
|
|
1854
1854
|
|
|
1855
1855
|
contract ShiftRNoParentheses {
|
|
1856
1856
|
function shiftRAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -1944,7 +1944,7 @@ contract ShiftRNoParentheses {
|
|
|
1944
1944
|
|
|
1945
1945
|
=====================================output=====================================
|
|
1946
1946
|
// SPDX-License-Identifier: MIT
|
|
1947
|
-
pragma solidity 0.8.
|
|
1947
|
+
pragma solidity 0.8.10;
|
|
1948
1948
|
|
|
1949
1949
|
contract ShiftRNoParentheses {
|
|
1950
1950
|
function shiftRAdd(
|
|
@@ -2047,7 +2047,7 @@ printWidth: 80
|
|
|
2047
2047
|
| printWidth
|
|
2048
2048
|
=====================================input======================================
|
|
2049
2049
|
// SPDX-License-Identifier: MIT
|
|
2050
|
-
pragma solidity 0.8.
|
|
2050
|
+
pragma solidity 0.8.10;
|
|
2051
2051
|
|
|
2052
2052
|
contract SubNoParentheses {
|
|
2053
2053
|
function subAdd(uint256 a, uint256 b, uint256 c)
|
|
@@ -2141,7 +2141,7 @@ contract SubNoParentheses {
|
|
|
2141
2141
|
|
|
2142
2142
|
=====================================output=====================================
|
|
2143
2143
|
// SPDX-License-Identifier: MIT
|
|
2144
|
-
pragma solidity 0.8.
|
|
2144
|
+
pragma solidity 0.8.10;
|
|
2145
2145
|
|
|
2146
2146
|
contract SubNoParentheses {
|
|
2147
2147
|
function subAdd(
|
|
@@ -13,6 +13,7 @@ pragma solidity >0.4.21 <=0.6.0;
|
|
|
13
13
|
pragma solidity >=0.4.21<0.6.0;
|
|
14
14
|
pragma solidity ^ 0.4.21 ;
|
|
15
15
|
pragma solidity ~ 0.4.21 ;
|
|
16
|
+
pragma solidity ^0.5.0 || ^0.6.0 || ^0.7.0 ;
|
|
16
17
|
|
|
17
18
|
=====================================output=====================================
|
|
18
19
|
pragma solidity >=0.4.21 <0.6.0;
|
|
@@ -22,6 +23,7 @@ pragma solidity >0.4.21 <=0.6.0;
|
|
|
22
23
|
pragma solidity >=0.4.21 <0.6.0;
|
|
23
24
|
pragma solidity ^0.4.21;
|
|
24
25
|
pragma solidity ~0.4.21;
|
|
26
|
+
pragma solidity ^0.5.0 || ^0.6.0 || ^0.7.0;
|
|
25
27
|
|
|
26
28
|
================================================================================
|
|
27
29
|
`;
|
|
@@ -88,7 +88,7 @@ contract SplittableCommodity is MintableCommodity {
|
|
|
88
88
|
uint256 _amount
|
|
89
89
|
) public whenNotPaused {
|
|
90
90
|
address supplierProxy = IContractRegistry(contractRegistry)
|
|
91
|
-
|
|
91
|
+
.getLatestProxyAddr("Supplier");
|
|
92
92
|
require(
|
|
93
93
|
msg.sender ==
|
|
94
94
|
IContractRegistry(contractRegistry).getLatestProxyAddr(
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StringLiteral.sol format 1`] = `
|
|
4
|
+
====================================options=====================================
|
|
5
|
+
parsers: ["solidity-parse"]
|
|
6
|
+
printWidth: 80
|
|
7
|
+
| printWidth
|
|
8
|
+
=====================================input======================================
|
|
9
|
+
contract StringLiteral {
|
|
10
|
+
bytes32 public constant PERMIT_TYPEHASH = keccak256(
|
|
11
|
+
"Permit("
|
|
12
|
+
"address owner,"
|
|
13
|
+
"address spender,"
|
|
14
|
+
"uint256 value,"
|
|
15
|
+
"uint256 nonce,"
|
|
16
|
+
"uint256 deadline"
|
|
17
|
+
")"
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
=====================================output=====================================
|
|
22
|
+
contract StringLiteral {
|
|
23
|
+
bytes32 public constant PERMIT_TYPEHASH =
|
|
24
|
+
keccak256(
|
|
25
|
+
"Permit("
|
|
26
|
+
"address owner,"
|
|
27
|
+
"address spender,"
|
|
28
|
+
"uint256 value,"
|
|
29
|
+
"uint256 nonce,"
|
|
30
|
+
"uint256 deadline"
|
|
31
|
+
")"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
================================================================================
|
|
36
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
run_spec(__dirname, ['solidity-parse']);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`TypeDefinition.sol format 1`] = `
|
|
4
|
+
====================================options=====================================
|
|
5
|
+
parsers: ["solidity-parse"]
|
|
6
|
+
printWidth: 80
|
|
7
|
+
| printWidth
|
|
8
|
+
=====================================input======================================
|
|
9
|
+
pragma solidity ^0.8.8;
|
|
10
|
+
|
|
11
|
+
type Hello is uint;
|
|
12
|
+
|
|
13
|
+
contract TypeDefinition {
|
|
14
|
+
event Moon(Hello world);
|
|
15
|
+
|
|
16
|
+
function demo(Hello world) public {
|
|
17
|
+
world = Hello.wrap(Hello.unwrap(world) + 1337);
|
|
18
|
+
emit Moon(world);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
=====================================output=====================================
|
|
24
|
+
pragma solidity ^0.8.8;
|
|
25
|
+
|
|
26
|
+
type Hello is uint256;
|
|
27
|
+
|
|
28
|
+
contract TypeDefinition {
|
|
29
|
+
event Moon(Hello world);
|
|
30
|
+
|
|
31
|
+
function demo(Hello world) public {
|
|
32
|
+
world = Hello.wrap(Hello.unwrap(world) + 1337);
|
|
33
|
+
emit Moon(world);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
================================================================================
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
exports[`TypeDefinition.sol format 1`] = `
|
|
41
|
+
====================================options=====================================
|
|
42
|
+
parsers: ["solidity-parse"]
|
|
43
|
+
printWidth: 80
|
|
44
|
+
| printWidth
|
|
45
|
+
=====================================input======================================
|
|
46
|
+
pragma solidity ^0.8.8;
|
|
47
|
+
|
|
48
|
+
type Hello is uint;
|
|
49
|
+
|
|
50
|
+
contract TypeDefinition {
|
|
51
|
+
event Moon(Hello world);
|
|
52
|
+
|
|
53
|
+
function demo(Hello world) public {
|
|
54
|
+
world = Hello.wrap(Hello.unwrap(world) + 1337);
|
|
55
|
+
emit Moon(world);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
=====================================output=====================================
|
|
60
|
+
pragma solidity ^0.8.8;
|
|
61
|
+
|
|
62
|
+
type Hello is uint256;
|
|
63
|
+
|
|
64
|
+
contract TypeDefinition {
|
|
65
|
+
event Moon(Hello world);
|
|
66
|
+
|
|
67
|
+
function demo(Hello world) public {
|
|
68
|
+
world = Hello.wrap(Hello.unwrap(world) + 1337);
|
|
69
|
+
emit Moon(world);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
================================================================================
|
|
74
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
run_spec(__dirname, ['solidity-parse']);
|
|
@@ -53,9 +53,15 @@ contract Foo {
|
|
|
53
53
|
bytes8 hex2 = hex"DeadBeef";
|
|
54
54
|
string withUnicode1 = unicode"hello π¦ world";
|
|
55
55
|
string withUnicode2 = unicode"hello π¦ world";
|
|
56
|
-
string multiPartAndUnicode1 =
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
string multiPartAndUnicode1 =
|
|
57
|
+
unicode"hello π¦"
|
|
58
|
+
" world";
|
|
59
|
+
string multiPartAndUnicode2 =
|
|
60
|
+
"hello "
|
|
61
|
+
unicode" π¦world";
|
|
62
|
+
string multiPartAndUnicode3 =
|
|
63
|
+
unicode"hello π¦"
|
|
64
|
+
unicode" world π¦";
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
================================================================================
|
|
@@ -114,9 +120,15 @@ contract Foo {
|
|
|
114
120
|
bytes8 hex2 = hex'DeadBeef';
|
|
115
121
|
string withUnicode1 = unicode'hello π¦ world';
|
|
116
122
|
string withUnicode2 = unicode'hello π¦ world';
|
|
117
|
-
string multiPartAndUnicode1 =
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
string multiPartAndUnicode1 =
|
|
124
|
+
unicode'hello π¦'
|
|
125
|
+
' world';
|
|
126
|
+
string multiPartAndUnicode2 =
|
|
127
|
+
'hello '
|
|
128
|
+
unicode' π¦world';
|
|
129
|
+
string multiPartAndUnicode3 =
|
|
130
|
+
unicode'hello π¦'
|
|
131
|
+
unicode' world π¦';
|
|
120
132
|
}
|
|
121
133
|
|
|
122
134
|
================================================================================
|