forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ethereum#8203 from ethereum/extract-tests
Extract some semantic tests
- Loading branch information
Showing
4 changed files
with
64 additions
and
82 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
22 changes: 22 additions & 0 deletions
22
test/libsolidity/semanticTests/functionCall/member_accessors.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,22 @@ | ||
contract test { | ||
uint256 public data; | ||
bytes6 public name; | ||
bytes32 public a_hash; | ||
address public an_address; | ||
constructor() public { | ||
data = 8; | ||
name = "Celina"; | ||
a_hash = keccak256("\x7b"); | ||
an_address = address(0x1337); | ||
super_secret_data = 42; | ||
} | ||
uint256 super_secret_data; | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// data() -> 8 | ||
// name() -> "Celina" | ||
// a_hash() -> 0xa91eddf639b0b768929589c1a9fd21dcb0107199bdd82e55c5348018a1572f52 | ||
// an_address() -> 0x1337 | ||
// super_secret_data() -> FAILURE |
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,27 @@ | ||
contract test { | ||
mapping(uint8 => uint8) table; | ||
function get(uint8 k) public returns (uint8 v) { | ||
return table[k]; | ||
} | ||
function set(uint8 k, uint8 v) public { | ||
table[k] = v; | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// get(uint8): 0 -> 0 | ||
// get(uint8): 0x01 -> 0 | ||
// get(uint8): 0xa7 -> 0 | ||
// set(uint8,uint8): 0x01, 0xa1 -> | ||
// get(uint8): 0 -> 0 | ||
// get(uint8): 0x01 -> 0xa1 | ||
// get(uint8): 0xa7 -> 0 | ||
// set(uint8,uint8): 0x00, 0xef -> | ||
// get(uint8): 0 -> 0xef | ||
// get(uint8): 0x01 -> 0xa1 | ||
// get(uint8): 0xa7 -> 0 | ||
// set(uint8,uint8): 0x01, 0x05 -> | ||
// get(uint8): 0 -> 0xef | ||
// get(uint8): 0x01 -> 0x05 | ||
// get(uint8): 0xa7 -> 0 |
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,15 @@ | ||
contract test { | ||
function fixedBytes() public returns(bytes32 ret) { | ||
return "abc\x00\xff__"; | ||
} | ||
function pipeThrough(bytes2 small, bool one) public returns(bytes16 large, bool oneRet) { | ||
oneRet = one; | ||
large = small; | ||
} | ||
} | ||
|
||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// fixedBytes() -> "abc\0\xff__" | ||
// pipeThrough(bytes2, bool): "\0\x02", true -> "\0\x2", true |