-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Extracted test cases from SolidityEndToEnd.cpp #12300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chriseth
merged 1 commit into
argotorg:develop
from
nishant-sachdeva:extracting_tests_from_solEndToEnd.cpp
Nov 29, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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" |
27 changes: 27 additions & 0 deletions
27
test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol
This file contains hidden or 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 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; | ||
| } | ||
| } | ||
| // ==== | ||
| // compileViaYul: also | ||
| // ---- | ||
| // test() -> 1 | ||
| // storageEmpty -> 1 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.