Merge branch 'develop' into client_ref

This commit is contained in:
Marek Kotewicz 2015-07-14 18:53:38 +02:00
commit 6b068c6726
3 changed files with 41 additions and 1 deletions

View File

@ -479,7 +479,7 @@ bytes importCode(json_spirit::mObject& _o)
{
bytes code;
if (_o["code"].type() == json_spirit::str_type)
if (_o["code"].get_str().find_first_of("0x") != 0)
if (_o["code"].get_str().find("0x") != 0)
code = compileLLL(_o["code"].get_str(), false);
else
code = fromHex(_o["code"].get_str().substr(2));

View File

@ -585,6 +585,22 @@ BOOST_AUTO_TEST_CASE(inc_dec_operators)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(0x53866));
}
BOOST_AUTO_TEST_CASE(bytes_comparison)
{
char const* sourceCode = R"(
contract test {
function f() returns (bool) {
bytes2 a = "a";
bytes2 x = "aa";
bytes2 b = "b";
return a < x && x < b;
}
}
)";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("f()") == encodeArgs(true));
}
BOOST_AUTO_TEST_CASE(state_smoke_test)
{
char const* sourceCode = "contract test {\n"

View File

@ -2110,6 +2110,30 @@ BOOST_AUTO_TEST_CASE(literal_strings)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
BOOST_AUTO_TEST_CASE(invalid_integer_literal_fraction)
{
char const* text = R"(
contract Foo {
function f() {
var x = 1.20;
}
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
BOOST_AUTO_TEST_CASE(invalid_integer_literal_exp)
{
char const* text = R"(
contract Foo {
function f() {
var x = 1e2;
}
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
BOOST_AUTO_TEST_SUITE_END()
}