mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10393 from ethereum/getters
Add more tests for getters
This commit is contained in:
commit
ec49f4c905
@ -1,20 +0,0 @@
|
|||||||
contract C {
|
|
||||||
uint8 public a;
|
|
||||||
uint16 public b;
|
|
||||||
uint128 public c;
|
|
||||||
uint public d;
|
|
||||||
constructor() {
|
|
||||||
a = 3;
|
|
||||||
b = 4;
|
|
||||||
c = 5;
|
|
||||||
d = 6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ====
|
|
||||||
// compileViaYul: also
|
|
||||||
// compileToEwasm: also
|
|
||||||
// ----
|
|
||||||
// a() -> 3
|
|
||||||
// b() -> 4
|
|
||||||
// c() -> 5
|
|
||||||
// d() -> 6
|
|
14
test/libsolidity/semanticTests/getters/string_and_bytes.sol
Normal file
14
test/libsolidity/semanticTests/getters/string_and_bytes.sol
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
contract C {
|
||||||
|
string public a;
|
||||||
|
string public b;
|
||||||
|
bytes public c;
|
||||||
|
constructor() {
|
||||||
|
a = "hello world";
|
||||||
|
b = hex"41424344";
|
||||||
|
c = hex"ff077fff";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// a() -> 0x20, 11, "hello world"
|
||||||
|
// b() -> 0x20, 4, "ABCD"
|
||||||
|
// c() -> 0x20, 4, -439061522557375173052089223601630338202760422010735733633791622124826263552
|
35
test/libsolidity/semanticTests/getters/value_types.sol
Normal file
35
test/libsolidity/semanticTests/getters/value_types.sol
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
contract C {
|
||||||
|
uint8 public a;
|
||||||
|
uint16 public b;
|
||||||
|
uint128 public c;
|
||||||
|
uint public d;
|
||||||
|
bytes1 public e;
|
||||||
|
bytes20 public f;
|
||||||
|
bytes32 public g;
|
||||||
|
bool public h;
|
||||||
|
address public i;
|
||||||
|
constructor() {
|
||||||
|
a = 3;
|
||||||
|
b = 4;
|
||||||
|
c = 5;
|
||||||
|
d = 6;
|
||||||
|
e = bytes1(uint8(0x7f));
|
||||||
|
f = bytes20(uint160(0x64656164626565663135646561640000000000000010));
|
||||||
|
g = bytes32(uint256(0x6465616462656566313564656164000000000000000000000000000000000010));
|
||||||
|
h = true;
|
||||||
|
i = address(type(uint160).max / 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileToEwasm: also
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// a() -> 3
|
||||||
|
// b() -> 4
|
||||||
|
// c() -> 5
|
||||||
|
// d() -> 6
|
||||||
|
// e() -> 0x7f00000000000000000000000000000000000000000000000000000000000000
|
||||||
|
// f() -> 0x6164626565663135646561640000000000000010000000000000000000000000
|
||||||
|
// g() -> 0x6465616462656566313564656164000000000000000000000000000000000010
|
||||||
|
// h() -> true
|
||||||
|
// i() -> 0x5555555555555555555555555555555555555555
|
Loading…
Reference in New Issue
Block a user