Browse Source

added test

Conflicts:
	test/libsolidity/SolidityEndToEndTest.cpp
cl-refactor
Liana Husikyan 10 years ago
parent
commit
10615249cf
  1. 5
      libsolidity/Token.h
  2. 51
      test/libsolidity/SolidityEndToEndTest.cpp

5
libsolidity/Token.h

@ -253,7 +253,6 @@ namespace solidity
K(UInt240, "uint240", 0) \
K(UInt248, "uint248", 0) \
K(UInt256, "uint256", 0) \
K(Bytes0, "bytes0", 0) \
K(Bytes1, "bytes1", 0) \
K(Bytes2, "bytes2", 0) \
K(Bytes3, "bytes3", 0) \
@ -305,8 +304,10 @@ namespace solidity
\
/* Identifiers (not keywords or future reserved words). */ \
T(Identifier, NULL, 0) \
/* Bytes0 token is used for empty string. */ \
T(Bytes0, NULL, 0) \
\
/* Keywords reserved for future. use*/ \
/* Keywords reserved for future. use. */ \
K(As, "as", 0) \
K(Case, "case", 0) \
K(Catch, "catch", 0) \

51
test/libsolidity/SolidityEndToEndTest.cpp

@ -567,7 +567,7 @@ BOOST_AUTO_TEST_CASE(strings)
BOOST_AUTO_TEST_CASE(empty_string_on_stack)
{
char const* sourceCode = "contract test {\n"
" function run(bytes0 empty, uint8 inp) returns(uint16 a, bytes0 b, bytes4 c) {\n"
" function run(string empty, uint8 inp) external returns(uint16 a, string b, bytes4 c) {\n"
" var x = \"abc\";\n"
" var y = \"\";\n"
" var z = inp;\n"
@ -3786,25 +3786,25 @@ BOOST_AUTO_TEST_CASE(packed_storage_structs_delete)
BOOST_CHECK(m_state.storage(m_contractAddress).empty());
}
BOOST_AUTO_TEST_CASE(packed_storage_structs_with_bytes0)
BOOST_AUTO_TEST_CASE(packed_storage_structs_with_empty_string)
{
char const* sourceCode = R"(
contract C {
struct str { uint8 a; bytes0 b; uint8 c; }
uint8 a;
bytes0 x;
uint8 b;
str data;
function test() returns (bool) {
a = 2;
b = 3;
data.a = 4;
data.c = 5;
delete x;
delete data.b;
return a == 2 && b == 3 && data.a == 4 && data.c == 5;
}
contract C {
struct str { uint8 a; string b; uint8 c; }
uint8 a;
uint8 b;
str data;
function test() returns (bool) {
a = 2;
b = 3;
var x = "";
data.a = 4;
data.c = 5;
delete x;
delete data.b;
return a == 2 && b == 3 && data.a == 4 && data.c == 5;
}
}
)";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("test()") == encodeArgs(true));
@ -4172,6 +4172,23 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund)
BOOST_CHECK(compileAndRunWthoutCheck(sourceCode, 0, "A").empty());
}
BOOST_AUTO_TEST_CASE(empty_string)
{
char const* sourceCode = R"(
contract Foo {
var sEmpty = "";
string sStateVar = "text";
function Foo()
{
var sLocal = "";
sEmpty = sLocal;
sLocal = s;
}
}
)";
compileAndRun(sourceCode, 0, "Foo");
}
BOOST_AUTO_TEST_CASE(positive_integers_to_signed)
{
char const* sourceCode = R"(

Loading…
Cancel
Save