InlineAssembly: Extracting tests for function definition and calls.

This commit is contained in:
Christian Parpart 2020-10-19 15:42:47 +02:00
parent f2117b87f7
commit 55f9eab51f
6 changed files with 36 additions and 44 deletions

View File

@ -217,21 +217,6 @@ BOOST_AUTO_TEST_CASE(number_literals)
CHECK_STRICT_ERROR("{ let x := 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff }", TypeError, "Number literal too large (> 256 bits)");
}
BOOST_AUTO_TEST_CASE(function_definitions)
{
BOOST_CHECK(successParse("{ function f() { } function g(a) -> x { } }"));
}
BOOST_AUTO_TEST_CASE(function_definitions_multiple_args)
{
BOOST_CHECK(successParse("{ function f(a, d) { } function g(a, d) -> x, y { } }"));
}
BOOST_AUTO_TEST_CASE(function_calls)
{
BOOST_CHECK(successParse("{ function f(a) -> b {} function g(a, b, c) {} function x() { g(1, 2, f(mul(2, 3))) x() } }"));
}
BOOST_AUTO_TEST_CASE(opcode_for_functions)
{
CHECK_PARSE_ERROR("{ function gas() { } }", ParserError, "Cannot use builtin");
@ -267,11 +252,6 @@ BOOST_AUTO_TEST_CASE(name_clashes_function_variable_subscope_reverse)
{
CHECK_PARSE_ERROR("{ { let g := 0 } function g() { } }", DeclarationError, "Variable name g already taken in this scope");
}
BOOST_AUTO_TEST_CASE(functions_in_parallel_scopes)
{
BOOST_CHECK(successParse("{ { function g() {} } { function g() {} } }"));
}
BOOST_AUTO_TEST_CASE(variable_access_cross_functions)
{
CHECK_PARSE_ERROR("{ let x := 2 function g() { pop(x) } }", DeclarationError, "Identifier not found.");
@ -454,29 +434,6 @@ BOOST_AUTO_TEST_CASE(revert)
BOOST_CHECK(successAssemble("{ revert(0, 0) }"));
}
BOOST_AUTO_TEST_CASE(function_calls)
{
BOOST_CHECK(successAssemble("{ function f() {} }"));
BOOST_CHECK(successAssemble("{ function f() { let y := 2 } }"));
BOOST_CHECK(successAssemble("{ function f() -> z { let y := 2 } }"));
BOOST_CHECK(successAssemble("{ function f(a) { let y := 2 } }"));
BOOST_CHECK(successAssemble("{ function f(a) { let y := a } }"));
BOOST_CHECK(successAssemble("{ function f() -> x, y, z {} }"));
BOOST_CHECK(successAssemble("{ function f(x, y, z) {} }"));
BOOST_CHECK(successAssemble("{ function f(a, b) -> x, y, z { y := a } }"));
BOOST_CHECK(successAssemble("{ function f() {} f() }"));
BOOST_CHECK(successAssemble("{ function f() -> x, y { x := 1 y := 2} let a, b := f() }"));
BOOST_CHECK(successAssemble("{ function f(a, b) -> x, y { x := b y := a } let a, b := f(2, 3) }"));
BOOST_CHECK(successAssemble("{ function rec(a) { rec(sub(a, 1)) } rec(2) }"));
BOOST_CHECK(successAssemble("{ let r := 2 function f() -> x, y { x := 1 y := 2} let a, b := f() b := r }"));
BOOST_CHECK(successAssemble("{ function f() { g() } function g() { f() } }"));
}
BOOST_AUTO_TEST_CASE(embedded_functions)
{
BOOST_CHECK(successAssemble("{ function f(r, s) -> x { function g(a) -> b { } x := g(2) } let x := f(2, 3) }"));
}
BOOST_AUTO_TEST_CASE(large_constant)
{
auto source = R"({

View File

@ -0,0 +1,17 @@
{
{ function f() {} }
{ function f() { let y := 2 } }
{ function f() -> z { let y := 2 } }
{ function f(a) { let y := 2 } }
{ function f(a) { let y := a } }
{ function f() -> x, y, z {} }
{ function f(x, y, z) {} }
{ function f(a, b) -> x, y, z { y := a } }
{ function f() {} f() }
{ function f() -> x, y { x := 1 y := 2} let a, b := f() }
{ function f(a, b) -> x, y { x := b y := a } let a, b := f(2, 3) }
{ function rec(a) { rec(sub(a, 1)) } rec(2) }
{ let r := 2 function f() -> x, y { x := 1 y := 2} let a, b := f() b := r }
{ function f() { g() } function g() { f() } }
{ function f(a) -> b {} function g(a, b, c) {} function x() { g(1, 2, f(mul(2, 3))) x() } }
}

View File

@ -0,0 +1,4 @@
{
function f(a, d) { }
function g(a, d) -> x, y { }
}

View File

@ -1,4 +1,7 @@
{
function f (a, b , c ) -> y,x,z {
}
}
function g() { }
function h(a) -> x { }
}

View File

@ -0,0 +1,7 @@
{
function f(r, s) -> x {
function g(a) -> b { }
x := g(2)
}
let x := f(2, 3)
}

View File

@ -0,0 +1,4 @@
{
{ function g() {} }
{ function g() {} }
}