Adjust and add more tests

This commit is contained in:
Alex Beregszaszi 2020-08-03 19:48:15 +01:00
parent 3a617f9cf2
commit 6e381326fe
6 changed files with 68 additions and 3 deletions

View File

@ -1,4 +1,4 @@
{"errors":[{"component":"general","formattedMessage":"A:1:40: TypeError: Unknown data object \"NamedObject.\".
{"errors":[{"component":"general","formattedMessage":"A:1:51: TypeError: Unknown data object \"NamedObject.\".
object \"NamedObject\" { code { let x := dataoffset(\"NamedObject.\") sstore(add(x, 0), 0) } object \"OtherObject\" { code { revert(0, 0) } } }
^--------^
","message":"Unknown data object \"NamedObject.\".","severity":"error","sourceLocation":{"end":49,"file":"A","start":39},"type":"TypeError"}]}
^------------^
","message":"Unknown data object \"NamedObject.\".","severity":"error","sourceLocation":{"end":64,"file":"A","start":50},"type":"TypeError"}]}

View File

@ -258,6 +258,16 @@ BOOST_AUTO_TEST_CASE(arg_to_dataoffset_must_be_literal)
CHECK_ERROR(code, TypeError, "Function expects direct literals as arguments.");
}
BOOST_AUTO_TEST_CASE(arg_to_dataoffset_must_be_string_literal)
{
string code = R"(
object "outer" {
code { let y := dataoffset(0) }
}
)";
CHECK_ERROR(code, TypeError, "Function expects string literal.");
}
BOOST_AUTO_TEST_CASE(arg_to_datasize_must_be_literal)
{
string code = R"(
@ -268,6 +278,16 @@ BOOST_AUTO_TEST_CASE(arg_to_datasize_must_be_literal)
CHECK_ERROR(code, TypeError, "Function expects direct literals as arguments.");
}
BOOST_AUTO_TEST_CASE(arg_to_datasize_must_be_string_literal)
{
string code = R"(
object "outer" {
code { let y := datasize(0) }
}
)";
CHECK_ERROR(code, TypeError, "Function expects string literal.");
}
BOOST_AUTO_TEST_CASE(args_to_datacopy_are_arbitrary)
{
string code = R"(

View File

@ -0,0 +1,12 @@
{
datacopy(0, 1, 2)
datasize("")
datasize(0) // This should not be valid.
dataoffset("")
dataoffset(0) // This should not be valid.
}
// ----
// TypeError 3517: (37-39): Unknown data object "".
// TypeError 5859: (54-55): Function expects string literal.
// TypeError 3517: (101-103): Unknown data object "".
// TypeError 5859: (120-121): Function expects string literal.

View File

@ -0,0 +1,11 @@
{
pop(linkersymbol(0))
pop(linkersymbol(true))
pop(linkersymbol(false))
}
// ====
// dialect: evm
// ----
// TypeError 5859: (23-24): Function expects string literal.
// TypeError 5859: (48-52): Function expects string literal.
// TypeError 5859: (76-81): Function expects string literal.

View File

@ -0,0 +1,11 @@
{
pop(loadimmutable(0))
pop(loadimmutable(true))
pop(loadimmutable(false))
}
// ====
// dialect: evm
// ----
// TypeError 5859: (24-25): Function expects string literal.
// TypeError 5859: (50-54): Function expects string literal.
// TypeError 5859: (79-84): Function expects string literal.

View File

@ -0,0 +1,11 @@
{
setimmutable(0, 0x1234567890123456789012345678901234567890)
setimmutable(true, 0x1234567890123456789012345678901234567890)
setimmutable(false, 0x1234567890123456789012345678901234567890)
}
// ====
// dialect: evm
// ----
// TypeError 5859: (19-20): Function expects string literal.
// TypeError 5859: (83-87): Function expects string literal.
// TypeError 5859: (150-155): Function expects string literal.