forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving some byte array pop tests to semanticTests.
- Loading branch information
Showing
4 changed files
with
57 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
contract c { | ||
uint256 a; | ||
uint256 b; | ||
uint256 c; | ||
bytes data; | ||
function test() public returns (bool) { | ||
for (uint8 i = 0; i <= 40; i++) | ||
data.push(byte(i+1)); | ||
for (int8 j = 40; j >= 0; j--) { | ||
require(data[uint8(j)] == byte(j+1)); | ||
require(data.length == uint8(j+1)); | ||
data.pop(); | ||
} | ||
return true; | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// test() -> true | ||
// storage: empty |
20 changes: 20 additions & 0 deletions
20
test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
contract c { | ||
uint256 a; | ||
uint256 b; | ||
bytes data; | ||
function test() public { | ||
for (uint8 i = 0; i <= 40; i++) | ||
data.push(0x03); | ||
for (uint8 j = 0; j <= 40; j++) { | ||
assembly { | ||
mstore(0, "garbage") | ||
} | ||
data.pop(); | ||
} | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// test() -> | ||
// storage: empty |
16 changes: 16 additions & 0 deletions
16
test/libsolidity/semanticTests/array/pop/byte_array_pop_storage_empty.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
contract c { | ||
bytes data; | ||
function test() public { | ||
data.push(0x07); | ||
data.push(0x05); | ||
data.push(0x03); | ||
data.pop(); | ||
data.pop(); | ||
data.pop(); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// test() -> | ||
// storage: empty |