aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-09 22:30:44 +0800
committerchriseth <c@ethdev.com>2015-09-09 22:30:44 +0800
commit598696b641c20dee2fb9e88f1183a119b3939da2 (patch)
tree8b52e179716e969a58a1343f4213c811f17df367 /test/libsolidity/SolidityEndToEndTest.cpp
parent69ff4b281b656635a9899f24ed9e73d0d0fcc903 (diff)
parent9967ae4038c52724e7e16cea49799bd5508615c5 (diff)
downloaddexon-solidity-598696b641c20dee2fb9e88f1183a119b3939da2.tar.gz
dexon-solidity-598696b641c20dee2fb9e88f1183a119b3939da2.tar.zst
dexon-solidity-598696b641c20dee2fb9e88f1183a119b3939da2.zip
Merge pull request #54 from chriseth/sol_fixConstantStrings
Fix for constant strings.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 3bb12f09..c99d295d 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -3700,7 +3700,7 @@ BOOST_AUTO_TEST_CASE(simple_constant_variables_test)
BOOST_AUTO_TEST_CASE(constant_variables)
{
- //for now constant specifier is valid only for uint bytesXX and enums
+ //for now constant specifier is valid only for uint, bytesXX, string and enums
char const* sourceCode = R"(
contract Foo {
uint constant x = 56;
@@ -5183,6 +5183,38 @@ BOOST_AUTO_TEST_CASE(accessor_for_const_state_variable)
BOOST_CHECK(callContractFunction("ticketPrice()") == encodeArgs(u256(555)));
}
+BOOST_AUTO_TEST_CASE(constant_string_literal)
+{
+ char const* sourceCode = R"(
+ contract Test {
+ bytes32 constant public b = "abcdefghijklmnopq";
+ string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
+
+ function Test() {
+ var xx = x;
+ var bb = b;
+ }
+ function getB() returns (bytes32) { return b; }
+ function getX() returns (string) { return x; }
+ function getX2() returns (string r) { r = x; }
+ function unused() returns (uint) {
+ "unusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunused";
+ return 2;
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode);
+ string longStr = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
+ string shortStr = "abcdefghijklmnopq";
+ BOOST_CHECK(callContractFunction("b()") == encodeArgs(shortStr));
+ BOOST_CHECK(callContractFunction("x()") == encodeDyn(longStr));
+ BOOST_CHECK(callContractFunction("getB()") == encodeArgs(shortStr));
+ BOOST_CHECK(callContractFunction("getX()") == encodeDyn(longStr));
+ BOOST_CHECK(callContractFunction("getX2()") == encodeDyn(longStr));
+ BOOST_CHECK(callContractFunction("unused()") == encodeArgs(2));
+}
+
BOOST_AUTO_TEST_CASE(storage_string_as_mapping_key_without_variable)
{
char const* sourceCode = R"(