aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp50
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp20
2 files changed, 44 insertions, 26 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 552352e4..831840e2 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -4576,31 +4576,33 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_keccak)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(dev::keccak256("abc")));
}
-BOOST_AUTO_TEST_CASE(assignment_to_const_array_vars)
-{
- char const* sourceCode = R"(
- contract C {
- uint[3] constant x = [uint(1), 2, 3];
- uint constant y = x[0] + x[1] + x[2];
- function f() returns (uint) { return y; }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction("f()") == encodeArgs(1 + 2 + 3));
-}
+// Disabled until https://github.com/ethereum/solidity/issues/715 is implemented
+//BOOST_AUTO_TEST_CASE(assignment_to_const_array_vars)
+//{
+// char const* sourceCode = R"(
+// contract C {
+// uint[3] constant x = [uint(1), 2, 3];
+// uint constant y = x[0] + x[1] + x[2];
+// function f() returns (uint) { return y; }
+// }
+// )";
+// compileAndRun(sourceCode);
+// BOOST_CHECK(callContractFunction("f()") == encodeArgs(1 + 2 + 3));
+//}
-BOOST_AUTO_TEST_CASE(constant_struct)
-{
- char const* sourceCode = R"(
- contract C {
- struct S { uint x; uint[] y; }
- S constant x = S(5, new uint[](4));
- function f() returns (uint) { return x.x; }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction("f()") == encodeArgs(5));
-}
+// Disabled until https://github.com/ethereum/solidity/issues/715 is implemented
+//BOOST_AUTO_TEST_CASE(constant_struct)
+//{
+// char const* sourceCode = R"(
+// contract C {
+// struct S { uint x; uint[] y; }
+// S constant x = S(5, new uint[](4));
+// function f() returns (uint) { return x.x; }
+// }
+// )";
+// compileAndRun(sourceCode);
+// BOOST_CHECK(callContractFunction("f()") == encodeArgs(5));
+//}
BOOST_AUTO_TEST_CASE(packed_storage_structs_uint)
{
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 90831ccd..71fef32d 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2183,6 +2183,22 @@ BOOST_AUTO_TEST_CASE(assigning_state_to_const_variable)
CHECK_ERROR(text, TypeError, "Initial value for constant variable has to be compile-time constant.");
}
+BOOST_AUTO_TEST_CASE(constant_string_literal_disallows_assignment)
+{
+ char const* text = R"(
+ contract Test {
+ string constant x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
+ function f() {
+ x[0] = "f";
+ }
+ }
+ )";
+
+ // Even if this is made possible in the future, we should not allow assignment
+ // to elements of constant arrays.
+ CHECK_ERROR(text, TypeError, "Index access for string is not possible.");
+}
+
BOOST_AUTO_TEST_CASE(assign_constant_function_value_to_constant)
{
char const* text = R"(
@@ -2231,7 +2247,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_array_vars)
uint[3] constant x = [uint(1), 2, 3];
}
)";
- CHECK_SUCCESS(text);
+ CHECK_ERROR(text, TypeError, "implemented");
}
BOOST_AUTO_TEST_CASE(constant_struct)
@@ -2242,7 +2258,7 @@ BOOST_AUTO_TEST_CASE(constant_struct)
S constant x = S(5, new uint[](4));
}
)";
- CHECK_SUCCESS(text);
+ CHECK_ERROR(text, TypeError, "implemented");
}
BOOST_AUTO_TEST_CASE(uninitialized_const_variable)