-
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 617dc66
Showing
7 changed files
with
141 additions
and
179 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" |
35 changes: 35 additions & 0 deletions
35
test/libsolidity/semanticTests/variables/storing_invalid_boolean.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,35 @@ | ||
contract C { | ||
event Ev(bool); | ||
bool public perm; | ||
function set() public returns(uint) { | ||
bool tmp; | ||
assembly { | ||
tmp := 5 | ||
} | ||
perm = tmp; | ||
return 1; | ||
} | ||
function ret() public returns(bool) { | ||
bool tmp; | ||
assembly { | ||
tmp := 5 | ||
} | ||
return tmp; | ||
} | ||
function ev() public returns(uint) { | ||
bool tmp; | ||
assembly { | ||
tmp := 5 | ||
} | ||
emit Ev(tmp); | ||
return 1; | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// set() -> 1 | ||
// perm() -> true | ||
// ret() -> true | ||
// ev() -> 1 | ||
// ~ emit Ev(bool): true |