Skip to content

Commit

Permalink
fixup! more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusaaguiar committed Apr 30, 2024
1 parent 0c541ab commit 29e04e2
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 14 deletions.
16 changes: 16 additions & 0 deletions test/cmdlineTests/storage_layout_transient_value_types/input.json
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"fileA": {
"content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\ncontract A { uint transient x; bytes32 transient b; address transient addr; }"
}
},
"settings": {
"outputSelection": {
"fileA": {
"A": [ "storageLayout" ],
"": [ "storageLayout" ]
}
}
}
}
69 changes: 69 additions & 0 deletions test/cmdlineTests/storage_layout_transient_value_types/output.json
@@ -0,0 +1,69 @@
{
"contracts":
{
"fileA":
{
"A":
{
"storageLayout":
{
"storage":
[
{
"astId": 3,
"contract": "fileA:A",
"label": "x",
"offset": 0,
"slot": "0",
"type": "t_uint256"
},
{
"astId": 5,
"contract": "fileA:A",
"label": "b",
"offset": 0,
"slot": "1",
"type": "t_bytes32"
},
{
"astId": 7,
"contract": "fileA:A",
"label": "addr",
"offset": 0,
"slot": "2",
"type": "t_address"
}
],
"types":
{
"t_address":
{
"encoding": "inplace",
"label": "address",
"numberOfBytes": "20"
},
"t_bytes32":
{
"encoding": "inplace",
"label": "bytes32",
"numberOfBytes": "32"
},
"t_uint256":
{
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
}
}
}
}
}
},
"sources":
{
"fileA":
{
"id": 0
}
}
}
8 changes: 8 additions & 0 deletions test/libsolidity/astPropertyTests/transient_data_location.sol
@@ -0,0 +1,8 @@
contract C {
/// TestVarDataLocation: storageLocation
/// TestVarName: name
uint transient transient;
}
// ----
// TestVarDataLocation: transient
// TestVarName: transient
@@ -0,0 +1,6 @@
contract C {
function f(uint[] transient transient x) public pure { }
}

// ----
// ParserError 3548: (45-54): Location already specified.
@@ -0,0 +1,5 @@
contract C {
uint storage transient x;
}
// ----
// ParserError 2314: (22-29): Expected identifier but got 'storage'
@@ -0,0 +1,5 @@
contract C {
uint transient storage x;
}
// ----
// ParserError 2314: (32-39): Expected identifier but got 'storage'
@@ -1,17 +1,16 @@
contract C {
contract test {
function f() public {
uint storage a1;
bytes16 storage b1;
uint memory a2;
bytes16 memory b2;
uint transient a3;
bytes16 transient b3;
uint storage a1;
bytes16 storage b1;
uint memory a2;
bytes16 memory b2;
uint transient a3;
bytes16 b3;
}
}
// ----
// TypeError 6651: (47-62): Data location can only be specified for array, struct or mapping types, but "storage" was given.
// TypeError 6651: (72-90): Data location can only be specified for array, struct or mapping types, but "storage" was given.
// TypeError 6651: (100-114): Data location can only be specified for array, struct or mapping types, but "memory" was given.
// TypeError 6651: (124-141): Data location can only be specified for array, struct or mapping types, but "memory" was given.
// TypeError 6651: (151-168): Data location can only be specified for array, struct or mapping types, but "transient" was given.
// TypeError 6651: (178-198): Data location can only be specified for array, struct or mapping types, but "transient" was given.
// TypeError 6651: (48-63): Data location can only be specified for array, struct or mapping types, but "storage" was given.
// TypeError 6651: (71-89): Data location can only be specified for array, struct or mapping types, but "storage" was given.
// TypeError 6651: (97-111): Data location can only be specified for array, struct or mapping types, but "memory" was given.
// TypeError 6651: (119-136): Data location can only be specified for array, struct or mapping types, but "memory" was given.
// TypeError 6651: (144-161): Data location can only be specified for array, struct or mapping types, but "transient" was given.
Expand Up @@ -10,6 +10,10 @@ contract test {
contract test {
error e1(string calldata a);
}
==== Source: D ====
contract test {
error e1(string transient a);
}
// ----
// ParserError 2314: (A:36-43): Expected ',' but got 'storage'
// ParserError 2314: (B:36-42): Expected ',' but got 'memory'
Expand Down
Expand Up @@ -10,6 +10,10 @@ contract test {
contract test {
event e1(string calldata a);
}
==== Source: D ====
contract test {
event e1(string transient a);
}
// ----
// ParserError 2314: (A:36-43): Expected ',' but got 'storage'
// ParserError 2314: (B:36-42): Expected ',' but got 'memory'
Expand Down
@@ -1,5 +1,5 @@
contract C {
event e(uint indexed transient a);
event e(string indexed transient a);
}
// ----
// TypeError 6651: (25-49): Data location can only be specified for array, struct or mapping types, but "transient" was given.
@@ -0,0 +1,9 @@
contract C {
function (uint transient x) external y;
function (uint[] transient w) external z;
}
// ----
// Warning 6162: (27-43): Naming function type parameters is deprecated.
// Warning 6162: (71-89): Naming function type parameters is deprecated.
// TypeError 6651: (27-43): Data location can only be specified for array, struct or mapping types, but "transient" was given.
// TypeError 6651: (71-89): Data location must be "memory" or "calldata" for parameter in function, but "transient" was given.
@@ -0,0 +1,5 @@
contract C {
function (uint transient) external transient y;
}
// ----
// Warning 6162: (27-41): Naming function type parameters is deprecated.
@@ -0,0 +1,6 @@
contract C {
function (uint transient x) external transient y;
}
// ----
// Warning 6162: (27-43): Naming function type parameters is deprecated.
// TypeError 6651: (27-43): Data location can only be specified for array, struct or mapping types, but "transient" was given.
Expand Up @@ -8,6 +8,12 @@ contract A {
modifier mod7(string calldata storage a) { _; }
modifier mod8(string calldata memory a) { _; }
modifier mod9(string calldata calldata a) { _; }
modifier modA(string transient storage a) { _; }
modifier modB(string transient memory a) { _; }
modifier modC(string transient calldata a) { _; }
modifier modD(string storage transient a) { _; }
modifier modE(string memory transient a) { _; }
modifier modF(string calldata transient a) { _; }
}
// ----
// ParserError 3548: (46-53): Location already specified.
Expand All @@ -19,3 +25,9 @@ contract A {
// ParserError 3548: (350-357): Location already specified.
// ParserError 3548: (402-408): Location already specified.
// ParserError 3548: (453-461): Location already specified.
// ParserError 3548: (507-514): Location already specified.
// ParserError 3548: (560-566): Location already specified.
// ParserError 3548: (612-620): Location already specified.
// ParserError 3548: (664-673): Location already specified.
// ParserError 3548: (716-725): Location already specified.
// ParserError 3548: (770-779): Location already specified.
@@ -0,0 +1,6 @@
contract A {
modifier mod2(uint[] transient b) { _; }
}
// ----
// TypeError 6651: (31-46): Data location can only be specified for array, struct or mapping types, but "transient" was given.
// TypeError 6651: (73-91): Data location must be "storage", "memory" or "calldata" for parameter in function, but "transient" was given.
@@ -0,0 +1,9 @@
contract C {
int transient x;
function f() public view returns (int) {
int y = x;
int w = -x;
return (x + w) * (y / x);
}
}
// ----

0 comments on commit 29e04e2

Please sign in to comment.