Add date/time language to solidity.

This commit is contained in:
Gav Wood 2015-03-04 17:35:23 +01:00
parent dfcbfd24fa
commit a20b4b548d
2 changed files with 24 additions and 7 deletions

View File

@ -264,6 +264,23 @@ BOOST_AUTO_TEST_CASE(ether_subdenominations)
BOOST_CHECK_EQUAL(scanner.next(), Token::SubEther);
}
BOOST_AUTO_TEST_CASE(time_subdenominations)
{
Scanner scanner(CharStream("seconds minutes hours days weeks years"));
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::SubSecond);
BOOST_CHECK_EQUAL(scanner.next(), Token::SubMinute);
BOOST_CHECK_EQUAL(scanner.next(), Token::SubHour);
BOOST_CHECK_EQUAL(scanner.next(), Token::SubDay);
BOOST_CHECK_EQUAL(scanner.next(), Token::SubWeek);
BOOST_CHECK_EQUAL(scanner.next(), Token::SubYear);
}
BOOST_AUTO_TEST_CASE(time_after)
{
Scanner scanner(CharStream("after 1"));
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::After);
}
BOOST_AUTO_TEST_SUITE_END()
}

View File

@ -78,8 +78,8 @@ bytes createBlockRLPFromFields(mObject& _tObj)
if (_tObj.count("seedHash"))
rlpStream << importByteArray(_tObj["seedHash"].get_str());
if (_tObj.count("mixBytes"))
rlpStream << importByteArray(_tObj["mixBytes"].get_str());
if (_tObj.count("mixHash"))
rlpStream << importByteArray(_tObj["mixHash"].get_str());
if (_tObj.count("nonce"))
rlpStream << importByteArray(_tObj["nonce"].get_str());
@ -146,7 +146,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
//update genesis block in json file
o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot);
o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce);
o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes);
o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash);
}
// create new "genesis" block
@ -276,8 +276,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
if (blObj["blockHeader"].get_obj().count("extraData"))
tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str());
if (blObj["blockHeader"].get_obj().count("mixBytes"))
tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str());
if (blObj["blockHeader"].get_obj().count("mixHash"))
tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str());
if (blObj["blockHeader"].get_obj().count("seedHash"))
tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str());
@ -322,7 +322,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed);
oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp);
oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData);
oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes);
oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash);
oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash);
oBlockHeader["nonce"] = toString(current_BlockHeader.nonce);
@ -445,7 +445,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixHash == blockFromRlp.mixHash, "mixHash in given RLP not matching the block mixHash!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!");