mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added arithmetic test
This commit is contained in:
parent
f9a7ab94ae
commit
9f04e1d1b7
58
vm.cpp
58
vm.cpp
@ -169,6 +169,15 @@ public:
|
|||||||
a.push_back(toString(_v));
|
a.push_back(toString(_v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string u256toHex(u256 const& _v)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << std::hex << std::setfill('0') << std::setw(2) << _v;
|
||||||
|
string ret = "0x" + oss.str();
|
||||||
|
std::transform(ret.begin(), ret.end(), ret.begin(), ::tolower);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
mObject exportEnv()
|
mObject exportEnv()
|
||||||
{
|
{
|
||||||
mObject ret;
|
mObject ret;
|
||||||
@ -219,13 +228,13 @@ public:
|
|||||||
if (li)
|
if (li)
|
||||||
store[curKey] = curVal;
|
store[curKey] = curVal;
|
||||||
li = s.first;
|
li = s.first;
|
||||||
curKey = toString(li);
|
curKey = u256toHex(li);
|
||||||
curVal = mArray();
|
curVal = mArray();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (; li != s.first; ++li)
|
for (; li != s.first; ++li)
|
||||||
curVal.push_back(0);
|
curVal.push_back(0);
|
||||||
push(curVal, s.second);
|
curVal.push_back(u256toHex(s.second));
|
||||||
++li;
|
++li;
|
||||||
}
|
}
|
||||||
if (li)
|
if (li)
|
||||||
@ -476,15 +485,15 @@ BOOST_AUTO_TEST_CASE(vm_tests)
|
|||||||
{
|
{
|
||||||
// Populate tests first:
|
// Populate tests first:
|
||||||
// try
|
// try
|
||||||
{
|
// {
|
||||||
cnote << "Populating VM tests...";
|
// cnote << "Populating VM tests...";
|
||||||
json_spirit::mValue v;
|
// json_spirit::mValue v;
|
||||||
string s = asString(contents("../../../cpp-ethereum/test/vmtests.json"));
|
// string s = asString(contents("../../../cpp-ethereum/test/vmtests.json"));
|
||||||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'vmtests.json' is empty.");
|
// BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'vmtests.json' is empty.");
|
||||||
json_spirit::read_string(s, v);
|
// json_spirit::read_string(s, v);
|
||||||
dev::test::doTests(v, true);
|
// dev::test::doTests(v, true);
|
||||||
writeFile("../../../tests/vmtests.json", asBytes(json_spirit::write_string(v, true)));
|
// writeFile("../../../tests/vmtests.json", asBytes(json_spirit::write_string(v, true)));
|
||||||
}
|
// }
|
||||||
/* catch (std::exception const& e)
|
/* catch (std::exception const& e)
|
||||||
{
|
{
|
||||||
BOOST_ERROR("Failed VM Test with Exception: " << e.what());
|
BOOST_ERROR("Failed VM Test with Exception: " << e.what());
|
||||||
@ -504,3 +513,30 @@ BOOST_AUTO_TEST_CASE(vm_tests)
|
|||||||
BOOST_ERROR("Failed VM Test with Exception: " << e.what());
|
BOOST_ERROR("Failed VM Test with Exception: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(vmArithmeticTest)
|
||||||
|
{
|
||||||
|
|
||||||
|
// cnote << "Populating VM tests...";
|
||||||
|
// json_spirit::mValue v;
|
||||||
|
// string s = asString(contents("../../../cpp-ethereum/test/vmArithmeticTestFiller.json"));
|
||||||
|
// BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'vmtests.json' is empty.");
|
||||||
|
// json_spirit::read_string(s, v);
|
||||||
|
// dev::test::doTests(v, true);
|
||||||
|
// writeFile("../../../tests/vmArithmeticTest.json", asBytes(json_spirit::write_string(v, true)));
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cnote << "Testing VM arithmetic commands...";
|
||||||
|
json_spirit::mValue v;
|
||||||
|
string s = asString(contents("../../../tests/vmArithmeticTest.json"));
|
||||||
|
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'vmArithmeticTest.json' is empty. Have you cloned the 'tests' repo branch develop?");
|
||||||
|
json_spirit::read_string(s, v);
|
||||||
|
dev::test::doTests(v, false);
|
||||||
|
}
|
||||||
|
catch (std::exception const& e)
|
||||||
|
{
|
||||||
|
BOOST_ERROR("Failed VM arithmetic test with Exception: " << e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2055
vmArithmeticTestFiller.json
Normal file
2055
vmArithmeticTestFiller.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user