aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp4
-rw-r--r--test/libsolidity/ViewPureChecker.cpp62
2 files changed, 64 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 800f102b..6886fcd0 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -5234,7 +5234,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_variable_access_out_of_functions)
char const* text = R"(
contract test {
uint a;
- function f() {
+ function f() pure {
assembly {
function g() -> x { x := a_slot }
}
@@ -5921,7 +5921,7 @@ BOOST_AUTO_TEST_CASE(no_unused_inline_asm)
{
char const* text = R"(
contract C {
- function f() {
+ function f() pure {
uint a;
assembly {
a := 1
diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp
index 7099ffd7..fabd1bee 100644
--- a/test/libsolidity/ViewPureChecker.cpp
+++ b/test/libsolidity/ViewPureChecker.cpp
@@ -316,6 +316,68 @@ BOOST_AUTO_TEST_CASE(function_types)
CHECK_SUCCESS_NO_WARNINGS(text);
}
+BOOST_AUTO_TEST_CASE(creation)
+{
+ string text = R"(
+ contract D {}
+ contract C {
+ function f() { new D(); }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+}
+
+BOOST_AUTO_TEST_CASE(assembly)
+{
+ string text = R"(
+ contract C {
+ struct S { uint x; }
+ S s;
+ function e() pure {
+ assembly { mstore(keccak256(0, 20), mul(s_slot, 2)) }
+ }
+ function f() pure {
+ uint x;
+ assembly { x := 7 }
+ }
+ function g() view {
+ assembly { for {} 1 { pop(sload(0)) } { } }
+ }
+ function h() view {
+ assembly { function g() { pop(blockhash(20)) } }
+ }
+ function j() {
+ assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) }
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+}
+
+BOOST_AUTO_TEST_CASE(assembly_staticcall)
+{
+ string text = R"(
+ contract C {
+ function i() view {
+ assembly { pop(staticcall(0, 1, 2, 3, 4, 5)) }
+ }
+ }
+ )";
+ CHECK_WARNING(text, "only available after the Metropolis");
+}
+
+BOOST_AUTO_TEST_CASE(assembly_jump)
+{
+ string text = R"(
+ contract C {
+ function k() {
+ assembly { jump(2) }
+ }
+ }
+ )";
+ CHECK_WARNING(text, "low-level EVM features");
+}
+
BOOST_AUTO_TEST_SUITE_END()
}