mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update tests
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
contract C {
|
||||
function f(uint a, bytes memory b, uint c)
|
||||
public pure returns (uint, uint, byte, uint) {
|
||||
public pure returns (uint, uint, bytes1, uint) {
|
||||
return (a, b.length, b[3], c);
|
||||
}
|
||||
|
||||
function f_external(uint a, bytes calldata b, uint c)
|
||||
external pure returns (uint, uint, byte, uint) {
|
||||
external pure returns (uint, uint, bytes1, uint) {
|
||||
return (a, b.length, b[3], c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ contract C {
|
||||
function f(bytes memory a, bytes calldata b, uint[] memory c)
|
||||
external
|
||||
pure
|
||||
returns (uint, byte, uint, byte, uint, uint)
|
||||
returns (uint, bytes1, uint, bytes1, uint, uint)
|
||||
{
|
||||
return (a.length, a[1], b.length, b[2], c.length, c[3]);
|
||||
}
|
||||
function g() public returns (uint, byte, uint, byte, uint, uint) {
|
||||
function g() public returns (uint, bytes1, uint, bytes1, uint, uint) {
|
||||
uint[] memory x = new uint[](4);
|
||||
x[3] = 7;
|
||||
return this.f("abc", "def", x);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
pragma abicoder v2;
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
function f(uint a, bytes memory b, uint c)
|
||||
public pure returns (uint, uint, byte, uint) {
|
||||
public pure returns (uint, uint, bytes1, uint) {
|
||||
return (a, b.length, b[3], c);
|
||||
}
|
||||
|
||||
function f_external(uint a, bytes calldata b, uint c)
|
||||
external pure returns (uint, uint, byte, uint) {
|
||||
external pure returns (uint, uint, bytes1, uint) {
|
||||
return (a, b.length, b[3], c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
pragma abicoder v2;
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
function f(bytes memory a, bytes calldata b, uint[] memory c)
|
||||
external
|
||||
pure
|
||||
returns (uint, byte, uint, byte, uint, uint)
|
||||
returns (uint, bytes1, uint, bytes1, uint, uint)
|
||||
{
|
||||
return (a.length, a[1], b.length, b[2], c.length, c[3]);
|
||||
}
|
||||
function g() public returns (uint, byte, uint, byte, uint, uint) {
|
||||
function g() public returns (uint, bytes1, uint, bytes1, uint, uint) {
|
||||
uint[] memory x = new uint[](4);
|
||||
x[3] = 7;
|
||||
return this.f("abc", "def", x);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
contract c {
|
||||
byte[10] data1;
|
||||
bytes1[10] data1;
|
||||
bytes2[32] data2;
|
||||
function test() public returns (uint check, uint res1, uint res2) {
|
||||
uint i;
|
||||
@@ -7,7 +7,7 @@ contract c {
|
||||
data2[i] = 0xffff;
|
||||
check = uint(uint16(data2[31])) * 0x10000 | uint(uint16(data2[14]));
|
||||
for (i = 0; i < data1.length; ++i)
|
||||
data1[i] = byte(uint8(1 + i));
|
||||
data1[i] = bytes1(uint8(1 + i));
|
||||
data2 = data1;
|
||||
for (i = 0; i < 16; ++i)
|
||||
res1 |= uint(uint16(data2[i])) * 0x10000**i;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
bytes s;
|
||||
function f() external returns (byte) {
|
||||
function f() external returns (bytes1) {
|
||||
bytes memory data = "abcd";
|
||||
s = data;
|
||||
return s[0];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
bytes s = "abcd";
|
||||
function f() external returns (byte) {
|
||||
function f() external returns (bytes1) {
|
||||
bytes memory data = s;
|
||||
return data[0];
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ contract c {
|
||||
function f(uint len) public returns (bytes memory) {
|
||||
bytes memory x = new bytes(len);
|
||||
for (uint i = 0; i < len; i++)
|
||||
x[i] = byte(uint8(i));
|
||||
x[i] = bytes1(uint8(i));
|
||||
a = x;
|
||||
for (uint i = 0; i < len; i++)
|
||||
assert(a[i] == x[i]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
bytes s;
|
||||
function f(bytes calldata data) external returns (byte) {
|
||||
function f(bytes calldata data) external returns (bytes1) {
|
||||
s = data;
|
||||
return s[0];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
contract C {
|
||||
bytes data;
|
||||
bytes otherData;
|
||||
function fromMemory() public returns (byte) {
|
||||
function fromMemory() public returns (bytes1) {
|
||||
bytes memory t;
|
||||
uint[2] memory x;
|
||||
x[0] = type(uint).max;
|
||||
@@ -9,12 +9,12 @@ contract C {
|
||||
data.push();
|
||||
return data[0];
|
||||
}
|
||||
function fromCalldata(bytes calldata x) public returns (byte) {
|
||||
function fromCalldata(bytes calldata x) public returns (bytes1) {
|
||||
data = x;
|
||||
data.push();
|
||||
return data[0];
|
||||
}
|
||||
function fromStorage() public returns (byte) {
|
||||
function fromStorage() public returns (bytes1) {
|
||||
// zero-length but dirty higher order bits
|
||||
assembly { sstore(otherData.slot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) }
|
||||
data = otherData;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
contract Main {
|
||||
function f(bytes memory _s1, uint i1, uint i2, uint i3) public returns (byte c1, byte c2, byte c3) {
|
||||
function f(bytes memory _s1, uint i1, uint i2, uint i3) public returns (bytes1 c1, bytes1 c2, bytes1 c3) {
|
||||
c1 = _s1[i1];
|
||||
c2 = intern(_s1, i2);
|
||||
c3 = internIndirect(_s1)[i3];
|
||||
}
|
||||
function intern(bytes memory _s1, uint i) public returns (byte c) {
|
||||
function intern(bytes memory _s1, uint i) public returns (bytes1 c) {
|
||||
return _s1[i];
|
||||
}
|
||||
function internIndirect(bytes memory _s1) public returns (bytes memory) {
|
||||
|
||||
@@ -12,7 +12,7 @@ contract C {
|
||||
function abiEncode() public view returns (bytes memory) { return x; }
|
||||
function abiEncodePacked() public view returns (bytes memory) { return abi.encodePacked(x); }
|
||||
function copyToMemory() public view returns (bytes memory m) { m = x; }
|
||||
function indexAccess() public view returns (byte) { return x[0]; }
|
||||
function indexAccess() public view returns (bytes1) { return x[0]; }
|
||||
function assignTo() public { x = "def"; }
|
||||
function assignToLong() public { x = "1234567890123456789012345678901234567"; }
|
||||
function copyToStorage() public { y = x; }
|
||||
|
||||
@@ -5,9 +5,9 @@ contract c {
|
||||
bytes data;
|
||||
function test() public returns (bool) {
|
||||
for (uint8 i = 0; i <= 40; i++)
|
||||
data.push(byte(i+1));
|
||||
data.push(bytes1(i+1));
|
||||
for (int8 j = 40; j >= 0; j--) {
|
||||
require(data[uint8(j)] == byte(uint8(j+1)));
|
||||
require(data[uint8(j)] == bytes1(uint8(j+1)));
|
||||
require(data.length == uint8(j+1));
|
||||
data.pop();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ contract CalldataTest {
|
||||
function test(bytes calldata x) public returns (bytes calldata) {
|
||||
return x;
|
||||
}
|
||||
function tester(bytes calldata x) public returns (byte) {
|
||||
function tester(bytes calldata x) public returns (bytes1) {
|
||||
return this.test(x)[2];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
contract C {
|
||||
function f(bytes calldata b, uint i) internal pure returns (byte) {
|
||||
function f(bytes calldata b, uint i) internal pure returns (bytes1) {
|
||||
return b[i];
|
||||
}
|
||||
function f(uint, bytes calldata b, uint) external pure returns (byte) {
|
||||
function f(uint, bytes calldata b, uint) external pure returns (bytes1) {
|
||||
return f(b, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
contract C {
|
||||
function(bytes calldata) returns (byte) x;
|
||||
function(bytes calldata) returns (bytes1) x;
|
||||
constructor() { x = f; }
|
||||
function f(bytes calldata b) internal pure returns (byte) {
|
||||
function f(bytes calldata b) internal pure returns (bytes1) {
|
||||
return b[2];
|
||||
}
|
||||
function h(bytes calldata b) external returns (byte) {
|
||||
function h(bytes calldata b) external returns (bytes1) {
|
||||
return x(b);
|
||||
}
|
||||
function g() external returns (byte) {
|
||||
function g() external returns (bytes1) {
|
||||
bytes memory a = new bytes(34);
|
||||
a[2] = byte(uint8(7));
|
||||
a[2] = bytes1(uint8(7));
|
||||
return this.h(a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
library L {
|
||||
function f(uint, bytes calldata _x, uint) internal returns (byte) {
|
||||
function f(uint, bytes calldata _x, uint) internal returns (bytes1) {
|
||||
return _x[2];
|
||||
}
|
||||
}
|
||||
contract C {
|
||||
function f(bytes calldata a)
|
||||
external
|
||||
returns (byte)
|
||||
returns (bytes1)
|
||||
{
|
||||
return L.f(3, a, 9);
|
||||
}
|
||||
function g() public returns (byte) {
|
||||
function g() public returns (bytes1) {
|
||||
bytes memory x = new bytes(4);
|
||||
x[2] = 0x08;
|
||||
return this.f(x);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
contract C {
|
||||
function f(bytes memory _a, bytes calldata _b, bytes memory _c)
|
||||
public
|
||||
returns (uint, byte, byte, byte)
|
||||
returns (uint, bytes1, bytes1, bytes1)
|
||||
{
|
||||
return (_a.length + _b.length + _c.length, _a[1], _b[1], _c[1]);
|
||||
}
|
||||
function g() public returns (uint, byte, byte, byte) {
|
||||
function g() public returns (uint, bytes1, bytes1, bytes1) {
|
||||
bytes memory x = new bytes(3);
|
||||
bytes memory y = new bytes(4);
|
||||
bytes memory z = new bytes(7);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
contract C {
|
||||
address constant e = 0x1212121212121212121212121000002134593163;
|
||||
|
||||
function f() public returns (byte z) {
|
||||
function f() public returns (bytes1 z) {
|
||||
assembly { z := e }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ contract Base {
|
||||
m_x = x;
|
||||
m_s = s;
|
||||
}
|
||||
function part(uint i) public returns (byte) {
|
||||
function part(uint i) public returns (bytes1) {
|
||||
return m_s[i];
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ contract Main is Base {
|
||||
}
|
||||
}
|
||||
contract Creator {
|
||||
function f(uint x, bytes memory s) public returns (uint r, byte ch) {
|
||||
function f(uint x, bytes memory s) public returns (uint r, bytes1 ch) {
|
||||
Main c = new Main(s, x);
|
||||
r = c.m_x();
|
||||
ch = c.part(x);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
function f(bytes calldata b) public returns (bool correct) {
|
||||
byte a = b[3];
|
||||
bytes1 a = b[3];
|
||||
uint r;
|
||||
assembly {
|
||||
r := a
|
||||
|
||||
@@ -9,7 +9,7 @@ library D {
|
||||
|
||||
contract C {
|
||||
using D for bytes;
|
||||
function f(bytes calldata _x) public pure returns (byte, byte) {
|
||||
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
|
||||
return (_x.f()[0], _x.g()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ library D {
|
||||
|
||||
contract C {
|
||||
using D for bytes;
|
||||
function f(bytes calldata _x) public pure returns (byte, byte) {
|
||||
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
|
||||
return (_x.f()[0], _x.g()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
library D {
|
||||
function f(bytes calldata _x) internal pure returns (byte) {
|
||||
function f(bytes calldata _x) internal pure returns (bytes1) {
|
||||
return _x[0];
|
||||
}
|
||||
function g(bytes memory _x) internal pure returns (byte) {
|
||||
function g(bytes memory _x) internal pure returns (bytes1) {
|
||||
return _x[0];
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
using D for bytes;
|
||||
function f(bytes calldata _x) public pure returns (byte, byte) {
|
||||
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
|
||||
return (_x.f(), _x.g());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
library D {
|
||||
function f(bytes calldata _x) public pure returns (byte) {
|
||||
function f(bytes calldata _x) public pure returns (bytes1) {
|
||||
return _x[0];
|
||||
}
|
||||
function g(bytes memory _x) public pure returns (byte) {
|
||||
function g(bytes memory _x) public pure returns (bytes1) {
|
||||
return _x[0];
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
using D for bytes;
|
||||
function f(bytes calldata _x) public pure returns (byte, byte) {
|
||||
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
|
||||
return (_x.f(), _x.g());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
pragma abicoder v2;
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C
|
||||
{
|
||||
function f() public pure returns (uint, byte, byte) {
|
||||
function f() public pure returns (uint, bytes1, bytes1) {
|
||||
bytes memory encoded = abi.encodePacked("\\\\");
|
||||
return (encoded.length, encoded[0], encoded[1]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ contract C {
|
||||
function f(S1 calldata s1)
|
||||
external
|
||||
pure
|
||||
returns (uint256 a, uint64 b0, byte b1, uint256 c)
|
||||
returns (uint256 a, uint64 b0, bytes1 b1, uint256 c)
|
||||
{
|
||||
a = s1.a;
|
||||
b0 = s1.s.a;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pragma abicoder v2;
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
@@ -7,7 +7,7 @@ contract C {
|
||||
bytes2 c;
|
||||
}
|
||||
|
||||
function f(S calldata s) external pure returns (uint256, uint256, byte) {
|
||||
function f(S calldata s) external pure returns (uint256, uint256, bytes1) {
|
||||
S memory m = s;
|
||||
return (m.a, m.b, m.c[1]);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pragma abicoder v2;
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
@@ -10,7 +10,7 @@ contract C {
|
||||
uint[153] r;
|
||||
S s;
|
||||
|
||||
function f(uint32 a, S calldata c, uint256 b) external returns (uint256, uint256, byte) {
|
||||
function f(uint32 a, S calldata c, uint256 b) external returns (uint256, uint256, bytes1) {
|
||||
s = c;
|
||||
return (s.a, s.b, s.c[1]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ contract C {
|
||||
function f(S calldata c)
|
||||
external
|
||||
pure
|
||||
returns (uint256, byte, byte, uint256)
|
||||
returns (uint256, bytes1, bytes1, uint256)
|
||||
{
|
||||
S memory m = c;
|
||||
return (m.a, m.b[0], m.b[1], m.c);
|
||||
|
||||
@@ -16,7 +16,7 @@ contract c {
|
||||
delete data1;
|
||||
return true;
|
||||
}
|
||||
function test(uint256 i) public returns (byte) {
|
||||
function test(uint256 i) public returns (bytes1) {
|
||||
return data1.data[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ contract C {
|
||||
assembly {
|
||||
sstore(b.slot, or("deadbeef", 0x08))
|
||||
}
|
||||
byte s = b[3];
|
||||
bytes1 s = b[3];
|
||||
uint r;
|
||||
assembly {
|
||||
r := s
|
||||
|
||||
@@ -6,7 +6,7 @@ contract C {
|
||||
mstore(0, b.slot)
|
||||
sstore(keccak256(0, 0x20), "deadbeefdeadbeefdeadbeefdeadbeef")
|
||||
}
|
||||
byte s = b[31];
|
||||
bytes1 s = b[31];
|
||||
uint r;
|
||||
assembly {
|
||||
r := s
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
contract C {
|
||||
uint16 x;
|
||||
byte y;
|
||||
bytes1 y;
|
||||
uint16 z;
|
||||
function f(uint8 a) public returns (uint _x) {
|
||||
x = a;
|
||||
y = byte(uint8(x) + 1);
|
||||
y = bytes1(uint8(x) + 1);
|
||||
z = uint8(y) + 1;
|
||||
x = z + 1;
|
||||
_x = x;
|
||||
|
||||
@@ -32,9 +32,6 @@ contract C {
|
||||
function r_b1() public pure returns (bytes1) {
|
||||
return ~bytes1(hex"55");
|
||||
}
|
||||
function r_b() public pure returns (byte) {
|
||||
return ~byte(hex"55");
|
||||
}
|
||||
|
||||
function a_b32() public pure returns (bytes32) {
|
||||
bytes32 r = ~bytes32(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00");
|
||||
@@ -56,14 +53,10 @@ contract C {
|
||||
bytes4 r = ~bytes4(hex"ff00ff00");
|
||||
return r;
|
||||
}
|
||||
function a_b1() public pure returns (byte) {
|
||||
function a_b1() public pure returns (bytes1) {
|
||||
bytes1 r = ~bytes1(hex"55");
|
||||
return r;
|
||||
}
|
||||
function a_b() public pure returns (byte) {
|
||||
byte r = ~byte(hex"55");
|
||||
return r;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
@@ -77,11 +70,9 @@ contract C {
|
||||
// r_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
||||
// r_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
||||
// r_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
// r_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
// a_b32() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff
|
||||
// a_b25() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff0000000000000000
|
||||
// a_b16() -> 0xff00ff00ff00ff00ff00ff00ff00ff00000000000000000000000000000000
|
||||
// a_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
||||
// a_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
||||
// a_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
// a_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
Reference in New Issue
Block a user