Skip to content

Commit ec2ff6c

Browse files
authored
updating the code coverage on more niche syntaxes (#1425)
* updating the code coverage on more niche syntaxes * clean empty arguments in modifier * adding `YulEqualColon` and `YulColonEqual` to the format tests * Single `HexStringLiteral` and `UntypedTupleMember` with `storageLocation` * updating passing coverage requirements
1 parent 415eb45 commit ec2ff6c

31 files changed

Lines changed: 149 additions & 38 deletions

File tree

.c8rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"check-coverage": true,
3-
"branches": 90,
4-
"lines": 90,
5-
"functions": 90,
6-
"statements": 90,
3+
"branches": 95,
4+
"lines": 98,
5+
"functions": 100,
6+
"statements": 98,
77
"exclude": ["/node_modules/"],
88
"include": ["src/**/*.ts", "variant-coverage/**/*.ts"],
99
"reporter": ["lcov", "text"],

tests/config/run-format-test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ const unstableTests = new Map(
3333

3434
// Here we add files that will not have the same AST after being formatted.
3535
const unstableAstTests = new Map(
36-
[].map((fixture) => {
36+
[
37+
// `: =` and `= :` are syntactically the same as `:=` and `=:`, but the ast
38+
// changes from `YulColonAndEqual` and `YulEqualAndColon` to `ColonEqual`
39+
// and `EqualColon`, which is expected but the workaround to keep the test
40+
// stable is too much, so we just put it in this list.
41+
"AssemblyV0.4.26/Assembly.sol",
42+
].map((fixture) => {
3743
const [file, isAstUnstable = () => true] = Array.isArray(fixture)
3844
? fixture
3945
: [fixture];
@@ -73,6 +79,12 @@ const antlrMismatchTests = new Map(
7379
"IndexOf/IndexOf.sol",
7480
// Syntax for `pragma solidity 0.5.0 - 0.6.0;` not supported by ANTLR
7581
"Pragma/Pragma.sol",
82+
// ANTLR doesn't support assembly assignment operators separated by a space
83+
// like `: =` or `= :`
84+
"AssemblyV0.4.26/Assembly.sol",
85+
// ANTLR doesn't support UntypedTupleMember with a storage location, which
86+
// is valid Slang, but not in Solidity.
87+
"AllSolidityFeaturesV0.4.26/AllSolidityFeatures.sol",
7688
].map((fixture) => {
7789
const [file, compareBytecode = () => true] = Array.isArray(fixture)
7890
? fixture

tests/format/AllSolidityFeatures/AllSolidityFeatures.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ contract assemblyLocalBinding {
181181
let x := 0x00
182182
let y := x
183183
let z := "hello"
184+
let t := hex"0123456789abcdef"
184185
}
185186
}
186187
}

tests/format/AllSolidityFeatures/__snapshots__/format.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ contract assemblyLocalBinding {
189189
let x := 0x00
190190
let y := x
191191
let z := "hello"
192+
let t := hex"0123456789abcdef"
192193
}
193194
}
194195
}
@@ -545,6 +546,7 @@ contract assemblyLocalBinding {
545546
let x := 0x00
546547
let y := x
547548
let z := "hello"
549+
let t := hex"0123456789abcdef"
548550
}
549551
}
550552
}

tests/format/AllSolidityFeaturesV0.4.26/AllSolidityFeatures.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ contract test {
1818
var b = 7 + (c * (8 - 7)) - x;
1919
return -(-b | 0);
2020
}
21+
22+
function singleHexString() payable {
23+
string storage a = hex"ab1248fe";
24+
}
25+
26+
27+
function storageLocationsInTuple() {
28+
var (
29+
memory foo,
30+
storage bar,
31+
baz) =
32+
(0, 0, 0);
33+
// ~~~~~~ ~~~~~~~ => these are the storage locations
34+
}
2135
}
2236

2337
contract c {

tests/format/AllSolidityFeaturesV0.4.26/__snapshots__/format.test.js.snap

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ contract test {
2727
var b = 7 + (c * (8 - 7)) - x;
2828
return -(-b | 0);
2929
}
30+
31+
function singleHexString() payable {
32+
string storage a = hex"ab1248fe";
33+
}
34+
35+
36+
function storageLocationsInTuple() {
37+
var (
38+
memory foo,
39+
storage bar,
40+
baz) =
41+
(0, 0, 0);
42+
// ~~~~~~ ~~~~~~~ => these are the storage locations
43+
}
3044
}
3145
3246
contract c {
@@ -225,6 +239,15 @@ contract test {
225239
var b = 7 + (c * (8 - 7)) - x;
226240
return -(-b | 0);
227241
}
242+
243+
function singleHexString() payable {
244+
string storage a = hex"ab1248fe";
245+
}
246+
247+
function storageLocationsInTuple() {
248+
var (memory foo, storage bar, baz) = (0, 0, 0);
249+
// ~~~~~~ ~~~~~~~ => these are the storage locations
250+
}
228251
}
229252
230253
contract c {

tests/format/Assembly/Assembly.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
contract Assembly {
22
function ifAssembly() {
33
assembly {
4+
{
5+
success := 1
6+
}
47
if
58
returndatasize {
69
success := 0
@@ -51,6 +54,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
5154
-> result {
5255
result := add(x,
5356
1)
57+
leave
5458
}
5559
}
5660
}
@@ -61,6 +65,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
6165
-> result {
6266
result := add(a,
6367
add(b, c))
68+
leave
6469
}
6570
}
6671
}
@@ -70,6 +75,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
7075
function sum (thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines)
7176
-> result {
7277
result := 0
78+
leave
7379
}
7480
}
7581
}
@@ -83,6 +89,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
8389
veryLongParameterNames := 0
8490
andItAlsoHasALotOfParameters := 0
8591
soItShouldBeSplitInMultipleLines := 0
92+
leave
8693
}
8794
}
8895
}

tests/format/Assembly/__snapshots__/format.test.js.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ printWidth: 80
99
contract Assembly {
1010
function ifAssembly() {
1111
assembly {
12+
{
13+
success := 1
14+
}
1215
if
1316
returndatasize {
1417
success := 0
@@ -59,6 +62,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
5962
-> result {
6063
result := add(x,
6164
1)
65+
leave
6266
}
6367
}
6468
}
@@ -69,6 +73,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
6973
-> result {
7074
result := add(a,
7175
add(b, c))
76+
leave
7277
}
7378
}
7479
}
@@ -78,6 +83,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
7883
function sum (thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines)
7984
-> result {
8085
result := 0
86+
leave
8187
}
8288
}
8389
}
@@ -91,6 +97,7 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
9197
veryLongParameterNames := 0
9298
andItAlsoHasALotOfParameters := 0
9399
soItShouldBeSplitInMultipleLines := 0
100+
leave
94101
}
95102
}
96103
}
@@ -191,6 +198,9 @@ contract BooleanLiteralsInAssembly {
191198
contract Assembly {
192199
function ifAssembly() {
193200
assembly {
201+
{
202+
success := 1
203+
}
194204
if returndatasize {
195205
success := 0
196206
}
@@ -249,6 +259,7 @@ contract Assembly {
249259
assembly {
250260
function inc(x) -> result {
251261
result := add(x, 1)
262+
leave
252263
}
253264
}
254265
}
@@ -257,6 +268,7 @@ contract Assembly {
257268
assembly {
258269
function sum(a, b, c) -> result {
259270
result := add(a, add(b, c))
271+
leave
260272
}
261273
}
262274
}
@@ -271,6 +283,7 @@ contract Assembly {
271283
soItShouldBeSplitInMultipleLines
272284
) -> result {
273285
result := 0
286+
leave
274287
}
275288
}
276289
}
@@ -290,6 +303,7 @@ contract Assembly {
290303
veryLongParameterNames := 0
291304
andItAlsoHasALotOfParameters := 0
292305
soItShouldBeSplitInMultipleLines := 0
306+
leave
293307
}
294308
}
295309
}

tests/format/AssemblyV0.4.26/Assembly.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ contract MultipleAssemblyAssignment {
3939
function foo() public pure {
4040
assembly {
4141
function bar() -> a, b {
42+
b : = 2
4243
a := 1
4344
b := 2
4445
}
@@ -52,6 +53,7 @@ contract AssemblyStackAssignment {
5253
function f() public {
5354
assembly {
5455
4 =: y
56+
4 = : y
5557
}
5658
}
5759
}

tests/format/AssemblyV0.4.26/__snapshots__/format.test.js.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ contract MultipleAssemblyAssignment {
4747
function foo() public pure {
4848
assembly {
4949
function bar() -> a, b {
50+
b : = 2
5051
a := 1
5152
b := 2
5253
}
@@ -60,6 +61,7 @@ contract AssemblyStackAssignment {
6061
function f() public {
6162
assembly {
6263
4 =: y
64+
4 = : y
6365
}
6466
}
6567
}
@@ -108,6 +110,7 @@ contract MultipleAssemblyAssignment {
108110
function foo() public pure {
109111
assembly {
110112
function bar() -> a, b {
113+
b := 2
111114
a := 1
112115
b := 2
113116
}
@@ -122,6 +125,8 @@ contract AssemblyStackAssignment {
122125
assembly {
123126
4
124127
=: y
128+
4
129+
=: y
125130
}
126131
}
127132
}

0 commit comments

Comments
 (0)