From 53b635a21fe11aced02e25850f7e370571b271be Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 24 Nov 2020 22:32:32 +0000 Subject: [PATCH] Add more tests for getters --- .../semanticTests/getters/small_types.sol | 20 ----------- .../getters/string_and_bytes.sol | 14 ++++++++ .../semanticTests/getters/value_types.sol | 35 +++++++++++++++++++ 3 files changed, 49 insertions(+), 20 deletions(-) delete mode 100644 test/libsolidity/semanticTests/getters/small_types.sol create mode 100644 test/libsolidity/semanticTests/getters/string_and_bytes.sol create mode 100644 test/libsolidity/semanticTests/getters/value_types.sol diff --git a/test/libsolidity/semanticTests/getters/small_types.sol b/test/libsolidity/semanticTests/getters/small_types.sol deleted file mode 100644 index 7b82bcc40..000000000 --- a/test/libsolidity/semanticTests/getters/small_types.sol +++ /dev/null @@ -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 diff --git a/test/libsolidity/semanticTests/getters/string_and_bytes.sol b/test/libsolidity/semanticTests/getters/string_and_bytes.sol new file mode 100644 index 000000000..731d5678c --- /dev/null +++ b/test/libsolidity/semanticTests/getters/string_and_bytes.sol @@ -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 diff --git a/test/libsolidity/semanticTests/getters/value_types.sol b/test/libsolidity/semanticTests/getters/value_types.sol new file mode 100644 index 000000000..38a95dd36 --- /dev/null +++ b/test/libsolidity/semanticTests/getters/value_types.sol @@ -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