mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests
This commit is contained in:
parent
9417d6775f
commit
2c2269d300
19
test/libyul/controlFlowSideEffects/eval_order.yul
Normal file
19
test/libyul/controlFlowSideEffects/eval_order.yul
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
function a() -> x {
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
function b() -> x {
|
||||||
|
return(0, 0)
|
||||||
|
}
|
||||||
|
function c() {
|
||||||
|
sstore(a(), b())
|
||||||
|
}
|
||||||
|
function d() {
|
||||||
|
sstore(b(), a())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// a: can revert
|
||||||
|
// b: can terminate
|
||||||
|
// c: can terminate
|
||||||
|
// d: can revert
|
55
test/libyul/controlFlowSideEffects/for_loop.yul
Normal file
55
test/libyul/controlFlowSideEffects/for_loop.yul
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
function a() {
|
||||||
|
for { leave } calldataload(0) { } {
|
||||||
|
break
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function b() {
|
||||||
|
for { } calldataload(0) { leave } {
|
||||||
|
break
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function b2() {
|
||||||
|
for { } calldataload(0) { leave } {
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function c() {
|
||||||
|
for { } calldataload(0) { revert(0, 0) } {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function c2() {
|
||||||
|
for { } calldataload(0) { revert(0, 0) } {
|
||||||
|
break
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function d() {
|
||||||
|
for { } calldataload(0) { revert(0, 0) } {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function e() {
|
||||||
|
for { } calldataload(0) { revert(0, 0) } {
|
||||||
|
if calldataload(1) { break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f() {
|
||||||
|
for { } calldataload(0) { } {
|
||||||
|
if calldataload(1) { continue }
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// a: can continue
|
||||||
|
// b: can continue
|
||||||
|
// b2: can revert, can continue
|
||||||
|
// c: can continue
|
||||||
|
// c2: can continue
|
||||||
|
// d: can revert, can continue
|
||||||
|
// e: can revert, can continue
|
||||||
|
// f: can revert, can continue
|
13
test/libyul/controlFlowSideEffects/leave.yul
Normal file
13
test/libyul/controlFlowSideEffects/leave.yul
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
function a() {
|
||||||
|
revert(0, 0)
|
||||||
|
leave
|
||||||
|
}
|
||||||
|
function b() {
|
||||||
|
leave
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// a: can revert
|
||||||
|
// b: can continue
|
37
test/libyul/controlFlowSideEffects/recursion.yul
Normal file
37
test/libyul/controlFlowSideEffects/recursion.yul
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
function a() {
|
||||||
|
if calldataload(0) {
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
reg()
|
||||||
|
b()
|
||||||
|
}
|
||||||
|
function b() {
|
||||||
|
a()
|
||||||
|
return(0, 0)
|
||||||
|
}
|
||||||
|
function c() {
|
||||||
|
c()
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
function d() {
|
||||||
|
switch calldataload(0)
|
||||||
|
case 0 { x() }
|
||||||
|
case 1 { y() reg() revert(0, 0) }
|
||||||
|
default { z() }
|
||||||
|
}
|
||||||
|
function x() { d() revert(0, 0) }
|
||||||
|
function y() { reg() x() }
|
||||||
|
function z() { y() }
|
||||||
|
|
||||||
|
function reg() {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// a: can revert
|
||||||
|
// b: can revert
|
||||||
|
// c:
|
||||||
|
// d:
|
||||||
|
// reg: can continue
|
||||||
|
// x:
|
||||||
|
// y:
|
||||||
|
// z:
|
41
test/libyul/controlFlowSideEffects/switch.yul
Normal file
41
test/libyul/controlFlowSideEffects/switch.yul
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
function a() {
|
||||||
|
switch calldataload(0)
|
||||||
|
case 0 { revert(0, 0) }
|
||||||
|
}
|
||||||
|
function b() {
|
||||||
|
switch calldataload(0)
|
||||||
|
case 0 { revert(0, 0) }
|
||||||
|
default { revert(0, 0) }
|
||||||
|
}
|
||||||
|
function c() {
|
||||||
|
return(0, 0)
|
||||||
|
switch calldataload(0)
|
||||||
|
case 0 { revert(0, 0) }
|
||||||
|
default { }
|
||||||
|
}
|
||||||
|
function d() {
|
||||||
|
switch calldataload(0)
|
||||||
|
case 0 { return(0, 0) }
|
||||||
|
default { return(0, 0) }
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
function e() {
|
||||||
|
switch calldataload(0)
|
||||||
|
case 0 { return(0, 0) }
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
function f() {
|
||||||
|
switch calldataload(0)
|
||||||
|
case 0 { leave }
|
||||||
|
default { leave }
|
||||||
|
revert(0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// a: can revert, can continue
|
||||||
|
// b: can revert
|
||||||
|
// c: can terminate
|
||||||
|
// d: can terminate
|
||||||
|
// e: can terminate, can revert
|
||||||
|
// f: can continue
|
Loading…
Reference in New Issue
Block a user