aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-08 18:57:27 +0800
committerchriseth <c@ethdev.com>2015-09-08 22:51:14 +0800
commit985eb80695bf9c2a757397374a0ec30ea09d17c1 (patch)
treefda7e5e9e19744f78e24cc4e87a36d8af545fb0b /test/libsolidity/SolidityEndToEndTest.cpp
parentea981cb0f5e5b131a56e420db97e944644ac95d6 (diff)
downloaddexon-solidity-985eb80695bf9c2a757397374a0ec30ea09d17c1.tar
dexon-solidity-985eb80695bf9c2a757397374a0ec30ea09d17c1.tar.gz
dexon-solidity-985eb80695bf9c2a757397374a0ec30ea09d17c1.tar.bz2
dexon-solidity-985eb80695bf9c2a757397374a0ec30ea09d17c1.tar.lz
dexon-solidity-985eb80695bf9c2a757397374a0ec30ea09d17c1.tar.xz
dexon-solidity-985eb80695bf9c2a757397374a0ec30ea09d17c1.tar.zst
dexon-solidity-985eb80695bf9c2a757397374a0ec30ea09d17c1.zip
Fix for constant strings.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 3bb12f09..25b4e409 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -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"(