Tests, Docs and Changelog

This commit is contained in:
Harikrishnan Mulackal
2020-06-30 16:53:41 +05:30
parent d41eaeba56
commit eeadb5a6b5
48 changed files with 215 additions and 124 deletions
@@ -1,50 +0,0 @@
contract Test {
struct A {
mapping(uint=>uint) m;
}
struct B {
mapping(uint=>uint) m;
uint x;
}
struct C {
mapping(uint=>uint)[] ma;
}
struct D {
A[] a;
}
A storageA;
B storageB;
C storageC;
D storageD;
constructor() public {
storageA.m[1] = 2;
storageB.m[3] = 4;
storageB.x = 5;
for (uint i = 0; i < 6; i++)
storageC.ma.push();
for (uint i = 0; i < 7; i++)
storageD.a.push();
}
function run() public returns (uint, uint, uint, uint, uint, uint) {
A memory memoryA = A();
B memory memoryB = B(42);
C memory memoryC = C();
D memory memoryD1 = D(new A[](999));
D memory memoryD2 = storageD;
storageA = memoryA;
storageB = memoryB;
storageC = memoryC;
// the following line does not compile because unimplemented
// storageD = memoryD1;
return (
storageA.m[1],
storageB.x,
memoryB.x,
storageC.ma.length,
memoryD1.a.length,
memoryD2.a.length
);
}
}
// ----
// run() -> 2, 42, 42, 6, 999, 7
@@ -1,24 +0,0 @@
contract Test {
struct S {
uint8 a;
mapping(uint256 => uint256) b;
uint8 c;
}
S s;
function f() public returns (uint256) {
S memory x;
if (x.a != 0 || x.c != 0) return 1;
x.a = 4;
x.c = 5;
s = x;
if (s.a != 4 || s.c != 5) return 2;
x = S(2, 3);
if (x.a != 2 || x.c != 3) return 3;
x = s;
if (s.a != 4 || s.c != 5) return 4;
}
}
// ----
// f() -> 0
@@ -5,7 +5,6 @@ contract c {
}
struct Struct {
uint256 a;
mapping(uint256 => Struct) b;
Nested nested;
uint256 c;
}