Sort tests.

This commit is contained in:
chriseth
2020-03-19 14:42:25 +01:00
parent 8834b1acaf
commit f25157a5f8
295 changed files with 0 additions and 0 deletions
@@ -0,0 +1,21 @@
// tests that internal library functions can be called from outside
// and retain the same memory context (i.e. are pulled into the caller's code)
// This has to work without linking, because everything will be inlined.
library L {
function f(uint256[] memory _data) internal {
_data[3] = 2;
}
}
contract C {
function f() public returns (uint256) {
uint256[] memory x = new uint256[](7);
x[3] = 8;
L.f(x);
return x[3];
}
}
// ----
// f() -> 2
@@ -0,0 +1,26 @@
// This has to work without linking, because everything will be inlined.
library L {
struct S {
uint256[] data;
}
function f(S memory _s) internal {
_s.data[3] = 2;
}
}
contract C {
using L for L.S;
function f() public returns (uint256) {
L.S memory x;
x.data = new uint256[](7);
x.data[3] = 8;
x.f();
return x.data[3];
}
}
// ----
// f() -> 2
@@ -0,0 +1,26 @@
// tests that internal library functions that are called from outside and that
// themselves call private functions are still able to (i.e. the private function
// also has to be pulled into the caller's code)
// This has to work without linking, because everything will be inlined.
library L {
function g(uint256[] memory _data) private {
_data[3] = 2;
}
function f(uint256[] memory _data) internal {
g(_data);
}
}
contract C {
function f() public returns (uint256) {
uint256[] memory x = new uint256[](7);
x[3] = 8;
L.f(x);
return x[3];
}
}
// ----
// f() -> 2
@@ -0,0 +1,26 @@
// This has to work without linking, because everything will be inlined.
library L {
struct S {
uint256[] data;
}
function f(S memory _s) internal returns (uint256[] memory) {
_s.data[3] = 2;
return _s.data;
}
}
contract C {
using L for L.S;
function f() public returns (uint256) {
L.S memory x;
x.data = new uint256[](7);
x.data[3] = 8;
return x.f()[3];
}
}
// ----
// f() -> 2
@@ -0,0 +1,14 @@
library Arst {
enum Foo {Things, Stuff}
}
contract Tsra {
function f() public returns (uint256) {
Arst.Foo;
return 1;
}
}
// ----
// f() -> 1
@@ -0,0 +1,17 @@
library Arst {
struct Foo {
int256 Things;
int256 Stuff;
}
}
contract Tsra {
function f() public returns (uint256) {
Arst.Foo;
return 1;
}
}
// ----
// f() -> 1