Update existing tests.

This commit is contained in:
chriseth
2020-10-19 16:58:59 +02:00
parent 33d8b62d06
commit e61fa59593
35 changed files with 147 additions and 118 deletions
@@ -1,7 +1,9 @@
contract C {
function f() public pure returns (uint x) {
uint8 y = uint8(2)**uint8(8);
return 0**y;
unchecked {
uint8 y = uint8(2)**uint8(8);
return 0**y;
}
}
}
@@ -1,6 +1,8 @@
contract C {
function f() public pure returns (uint8 x) {
return uint8(0)**uint8(uint8(2)**uint8(8));
unchecked {
return uint8(0)**uint8(uint8(2)**uint8(8));
}
}
}
@@ -1,6 +1,8 @@
contract C {
function f() public pure returns (uint8 x) {
return uint8(0x166)**uint8(uint8(2)**uint8(8));
unchecked {
return uint8(0x166)**uint8(uint8(2)**uint8(8));
}
}
}
@@ -4,7 +4,9 @@ contract C {
// right before the exp
uint16 e = 0x100;
uint8 b = 0x2;
return b**e;
unchecked {
return b**e;
}
}
}
// ----
@@ -1,8 +1,10 @@
contract test {
function f(uint x) public pure returns (uint, int) {
uint a = 2 ** x;
int b = -2 ** x;
return (a, b);
unchecked {
uint a = 2 ** x;
int b = -2 ** x;
return (a, b);
}
}
}
// ----
@@ -1,12 +1,13 @@
contract test {
function f() public pure returns (uint) {
function f() public pure returns (uint r) {
uint32 x;
uint8 y;
assembly {
x := 0xfffffffffe
y := 0x102
}
return x**y;
unchecked { r = x**y; }
return r;
}
}
// ----
@@ -1,6 +1,6 @@
==== Source: s1.sol ====
import {f as g, g as h} from "s2.sol";
function f() pure returns (uint) { return h() - g(); }
function f() pure returns (uint) { return 1000 + g() - h(); }
==== Source: s2.sol ====
import {f as h} from "s1.sol";
function f() pure returns (uint) { return 2; }
@@ -10,5 +10,7 @@ contract C {
return h() - f() - g();
}
}
// ====
// compileViaYul: also
// ----
// foo() -> -4
// foo() -> 992
@@ -1,6 +1,6 @@
==== Source: s1.sol ====
import {f as g, g as h} from "s2.sol";
function f() pure returns (uint) { return h() - g(); }
function f() pure returns (uint) { return 100 + h() - g(); }
==== Source: s2.sol ====
import {f as h} from "s1.sol";
function f() pure returns (uint) { return 2; }
@@ -12,5 +12,7 @@ contract C {
return f() - g() - h();
}
}
// ====
// compileViaYul: also
// ----
// foo() -> -4
// foo() -> 0x60
@@ -1,6 +1,6 @@
==== Source: s1.sol ====
import {f as g, g as h} from "s2.sol";
function f() pure returns (uint) { return h() - g(); }
function f() pure returns (uint) { return 1000 + h() - g(); }
==== Source: s2.sol ====
import {f as h} from "s1.sol";
function f() pure returns (uint) { return 2; }
@@ -9,8 +9,10 @@ function g() pure returns (uint) { return 4; }
import "s2.sol";
contract C {
function foo() public pure returns (uint) {
return f() - g() - h();
return 10000 + f() - g() - h();
}
}
// ====
// compileViaYul: also
// ----
// foo() -> -4
// foo() -> 0x2324
@@ -1,11 +1,15 @@
contract C {
function f() public returns (uint16 x) {
x = 0xffff;
x += 32;
x <<= 8;
x >>= 16;
unchecked {
x = 0xffff;
x += 32;
x <<= 8;
x >>= 16;
}
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x0
@@ -13,7 +13,7 @@ contract C {
return (2, 3);
}
function h(uint x, uint y) public pure returns (uint) {
return x - y;
unchecked { return x - y; }
}
function i(bool b) public pure returns (bool) {
return !b;
@@ -28,6 +28,8 @@ contract C {
return a * 7;
}
}
// ====
// compileViaYul: also
// ----
// d() ->
// e(), 1 wei -> 1
@@ -4,10 +4,10 @@ contract C {
uint16 b;
function f() public returns (uint256, uint256, uint256, uint256) {
a++;
unchecked { a++; }
uint256 c = b;
delete b;
a -= 2;
unchecked { a -= 2; }
return (x, c, b, a);
}
}
@@ -9,8 +9,10 @@ contract C {
returns (uint256 x1, uint256 x2, uint256 x3, uint256 x4)
{
a = -2;
b = (0 - uint8(a)) * 2;
c = a * int8(120) * int8(121);
unchecked {
b = (0 - uint8(a)) * 2;
c = a * int8(120) * int8(121);
}
x1 = uint256(a);
x2 = b;
x3 = uint256(c);
@@ -18,5 +20,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// test() -> -2, 4, -112, 0
@@ -1,7 +1,7 @@
contract test {
function f() public returns (bool) {
int256 x = -2**255;
assert(-x == x);
unchecked { assert(-x == x); }
return true;
}
}
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(uint256,uint256): 5, 6 -> 11
// f(uint256,uint256): -2, 1 -> -1
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(int256,int256): 5, 6 -> 11
// f(int256,int256): -2, 1 -> -1
@@ -10,7 +10,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(uint256,uint256): 10, 3 -> 3
// f(uint256,uint256): 1, 0 -> FAILURE
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(uint256,uint256): 10, 3 -> 1
// f(uint256,uint256): 10, 2 -> 0
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(int256,int256): 10, 3 -> 1
// f(int256,int256): 10, 2 -> 0
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(uint256,uint256): 5, 6 -> 30
// f(uint256,uint256): -1, 1 -> -1
@@ -7,51 +7,42 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(int256,int256): 5, 6 -> 30
// f(int256,int256): -1, 1 -> -1
// f(int256,int256): -1, 2 -> -2
// # positive, positive #
// f(int256,int256): -1, 2 -> -2 # positive, positive #
// f(int256,int256): 0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 2 -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
// f(int256,int256): 0x4000000000000000000000000000000000000000000000000000000000000000, 2 -> FAILURE
// f(int256,int256): 2, 0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
// f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE
// # positive, negative #
// f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE # positive, negative #
// f(int256,int256): 0x4000000000000000000000000000000000000000000000000000000000000000, -2 -> 0x8000000000000000000000000000000000000000000000000000000000000000
// f(int256,int256): 0x4000000000000000000000000000000000000000000000000000000000000001, -2 -> FAILURE
// f(int256,int256): 2, 0xC000000000000000000000000000000000000000000000000000000000000000 -> 0x8000000000000000000000000000000000000000000000000000000000000000
// f(int256,int256): 2, 0xBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> FAILURE
// # negative, positive #
// f(int256,int256): 2, 0xBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> FAILURE # negative, positive #
// f(int256,int256): -2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> 0x8000000000000000000000000000000000000000000000000000000000000000
// f(int256,int256): -2, 0x4000000000000000000000000000000000000000000000000000000000000001 -> FAILURE
// f(int256,int256): 0xC000000000000000000000000000000000000000000000000000000000000000, 2 -> 0x8000000000000000000000000000000000000000000000000000000000000000
// f(int256,int256): 0xBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 2 -> FAILURE
// # negative, negative #
// f(int256,int256): 0xBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 2 -> FAILURE # negative, negative #
// f(int256,int256): 0xC000000000000000000000000000000000000000000000000000000000000001, -2 -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
// f(int256,int256): 0xC000000000000000000000000000000000000000000000000000000000000000, -2 -> FAILURE
// f(int256,int256): -2, 0xC000000000000000000000000000000000000000000000000000000000000001 -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
// f(int256,int256): -2, 0xC000000000000000000000000000000000000000000000000000000000000000 -> FAILURE
// # small type #
// f(int256,int256): -2, 0xC000000000000000000000000000000000000000000000000000000000000000 -> FAILURE # small type #
// g(int8,int8): 5, 6 -> 30
// g(int8,int8): -1, 1 -> -1
// g(int8,int8): -1, 2 -> -2
// # positive, positive #
// g(int8,int8): -1, 2 -> -2 # positive, positive #
// g(int8,int8): 63, 2 -> 126
// g(int8,int8): 64, 2 -> FAILURE
// g(int8,int8): 2, 63 -> 126
// g(int8,int8): 2, 64 -> FAILURE
// # positive, negative #
// g(int8,int8): 2, 64 -> FAILURE # positive, negative #
// g(int8,int8): 64, -2 -> -128
// g(int8,int8): 65, -2 -> FAILURE
// g(int8,int8): 2, -64 -> -128
// g(int8,int8): 2, -65 -> FAILURE
// # negative, positive #
// g(int8,int8): 2, -65 -> FAILURE # negative, positive #
// g(int8,int8): -2, 64 -> -128
// g(int8,int8): -2, 65 -> FAILURE
// g(int8,int8): -64, 2 -> -128
// g(int8,int8): -65, 2 -> FAILURE
// # negative, negative #
// g(int8,int8): -65, 2 -> FAILURE # negative, negative #
// g(int8,int8): -63, -2 -> 126
// g(int8,int8): -64, -2 -> FAILURE
// g(int8,int8): -2, -63 -> 126
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(uint256,uint256): 6, 5 -> 1
// f(uint256,uint256): 6, 6 -> 0
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(int256,int256): 5, 6 -> -1
// f(int256,int256): -2, 1 -> -3
@@ -101,4 +101,4 @@ contract ERC20 {
// decreaseAllowance(address,uint256): 2, 0 -> true
// decreaseAllowance(address,uint256): 2, 1 -> FAILURE
// transfer(address,uint256): 2, 14 -> true
// transfer(address,uint256): 2, 2 -> FAILURE
// transfer(address,uint256): 2, 2 -> FAILURE
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(int8,uint256): 2, 6 -> 64
// f(int8,uint256): 2, 7 -> FAILURE
@@ -7,7 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: true
// compileViaYul: also
// ----
// f(uint8,uint8): 2, 7 -> 0x80
// f(uint8,uint8): 2, 8 -> FAILURE