-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted some test cases from SolidityEndToEnd.cpp
- Loading branch information
1 parent
9b6a687
commit 52dd6c3
Showing
8 changed files
with
171 additions
and
210 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
24 changes: 24 additions & 0 deletions
24
test/libsolidity/semanticTests/enums/invalid_enum_logged.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,24 @@ | ||
contract C { | ||
enum X { A, B } | ||
event Log(X); | ||
|
||
function test_log() public returns (uint) { | ||
X garbled = X.A; | ||
assembly { | ||
garbled := 5 | ||
} | ||
emit Log(garbled); | ||
return 1; | ||
} | ||
function test_log_ok() public returns (uint) { | ||
X x = X.A; | ||
emit Log(x); | ||
return 1; | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// test_log_ok() -> 1 | ||
// ~ emit Log(uint8): 0x00 | ||
// test_log() -> FAILURE, hex"4e487b71", 0x21 |
20 changes: 20 additions & 0 deletions
20
test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.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 @@ | ||
library Lib { | ||
function x() public view returns (uint) { | ||
return 1; | ||
} | ||
} | ||
contract Test { | ||
uint t; | ||
function f() public returns (uint) { | ||
t = 2; | ||
return this.g(); | ||
} | ||
function g() public view returns (uint) { | ||
return Lib.x(); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// library: Lib | ||
// f() -> 1 |
17 changes: 17 additions & 0 deletions
17
test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.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,17 @@ | ||
contract Test { | ||
mapping(uint=>uint) data; | ||
function stat() public returns (uint[5] memory) | ||
{ | ||
data[2] = 3; // make sure to use some memory | ||
} | ||
function dyn() public returns (uint[] memory) { stat(); } | ||
function nested() public returns (uint[3][] memory) { stat(); } | ||
function nestedStat() public returns (uint[3][7] memory) { stat(); } | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// stat() -> 0, 0, 0, 0, 0 | ||
// dyn() -> 0x20, 0 | ||
// nested() -> 0x20, 0 | ||
// nestedStat() -> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
25 changes: 25 additions & 0 deletions
25
test/libsolidity/semanticTests/strings/constant_string_literal.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,25 @@ | ||
contract Test { | ||
bytes32 constant public b = "abcdefghijklmnopq"; | ||
string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca"; | ||
|
||
constructor() { | ||
string memory xx = x; | ||
bytes32 bb = b; | ||
} | ||
function getB() public returns (bytes32) { return b; } | ||
function getX() public returns (string memory) { return x; } | ||
function getX2() public returns (string memory r) { r = x; } | ||
function unused() public returns (uint) { | ||
"unusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunused"; | ||
return 2; | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// b() -> 0x6162636465666768696a6b6c6d6e6f7071000000000000000000000000000000 | ||
// x() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096 | ||
// getB() -> 0x6162636465666768696a6b6c6d6e6f7071000000000000000000000000000000 | ||
// getX() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096 | ||
// getX2() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096 | ||
// unused() -> 2 |
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 Main { | ||
string public s; | ||
function set(string calldata _s) external { | ||
s = _s; | ||
} | ||
function get1() public returns (string memory r) { | ||
return s; | ||
} | ||
function get2() public returns (string memory r) { | ||
r = s; | ||
} | ||
} | ||
// ==== | ||
// compileToEwasm: also | ||
// compileViaYul: also | ||
// ---- | ||
// set(string): 0x20, 5, "Julia" -> | ||
// get1() -> 0x20, 5, "Julia" | ||
// get2() -> 0x20, 5, "Julia" | ||
// s() -> 0x20, 5, "Julia" |
30 changes: 30 additions & 0 deletions
30
test/libsolidity/semanticTests/structs/packed_storage_structs_delete.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,30 @@ | ||
contract C { | ||
struct str { uint8 a; uint16 b; uint8 c; } | ||
uint8 x; | ||
uint16 y; | ||
str data; | ||
function test() public returns (uint) { | ||
x = 1; | ||
y = 2; | ||
data.a = 2; | ||
data.b = 0xabcd; | ||
data.c = 0xfa; | ||
if (x != 1 || y != 2 || data.a != 2 || data.b != 0xabcd || data.c != 0xfa) | ||
return 2; | ||
delete y; | ||
delete data.b; | ||
if (x != 1 || y != 0 || data.a != 2 || data.b != 0 || data.c != 0xfa) | ||
return 3; | ||
delete x; | ||
delete data; | ||
return 1; | ||
} | ||
function checkIfDataIsEmpty() public returns (bool) { | ||
return (x == 0 && y == 0 && data.a == 0 && data.b == 0 && data.c == 0); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// test() -> 1 | ||
// checkIfDataIsEmpty() -> true |
Oops, something went wrong.