mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1483 from federicobond/r-literals
Migrate remaining source code in tests to R literals
This commit is contained in:
commit
29edf2f4c9
@ -63,9 +63,11 @@ BOOST_FIXTURE_TEST_SUITE(SolidityABIJSON, JSONInterfaceChecker)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(basic_test)
|
BOOST_AUTO_TEST_CASE(basic_test)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint a) returns(uint d) { return a * 7; }\n"
|
contract test {
|
||||||
"}\n";
|
function f(uint a) returns(uint d) { return a * 7; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -93,8 +95,9 @@ BOOST_AUTO_TEST_CASE(basic_test)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(empty_contract)
|
BOOST_AUTO_TEST_CASE(empty_contract)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
"}\n";
|
contract test { }
|
||||||
|
)";
|
||||||
char const* interface = "[]";
|
char const* interface = "[]";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, interface);
|
||||||
@ -102,10 +105,12 @@ BOOST_AUTO_TEST_CASE(empty_contract)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiple_methods)
|
BOOST_AUTO_TEST_CASE(multiple_methods)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint a) returns(uint d) { return a * 7; }\n"
|
contract test {
|
||||||
" function g(uint b) returns(uint e) { return b * 8; }\n"
|
function f(uint a) returns(uint d) { return a * 7; }
|
||||||
"}\n";
|
function g(uint b) returns(uint e) { return b * 8; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -151,9 +156,11 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiple_params)
|
BOOST_AUTO_TEST_CASE(multiple_params)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint a, uint b) returns(uint d) { return a + b; }\n"
|
contract test {
|
||||||
"}\n";
|
function f(uint a, uint b) returns(uint d) { return a + b; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -186,10 +193,12 @@ BOOST_AUTO_TEST_CASE(multiple_params)
|
|||||||
BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
||||||
{
|
{
|
||||||
// methods are expected to be in alpabetical order
|
// methods are expected to be in alpabetical order
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint a) returns(uint d) { return a * 7; }\n"
|
contract test {
|
||||||
" function c(uint b) returns(uint e) { return b * 8; }\n"
|
function f(uint a) returns(uint d) { return a * 7; }
|
||||||
"}\n";
|
function c(uint b) returns(uint e) { return b * 8; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -235,10 +244,12 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(const_function)
|
BOOST_AUTO_TEST_CASE(const_function)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function foo(uint a, uint b) returns(uint d) { return a + b; }\n"
|
contract test {
|
||||||
" function boo(uint32 a) constant returns(uint b) { return a * 4; }\n"
|
function foo(uint a, uint b) returns(uint d) { return a + b; }
|
||||||
"}\n";
|
function boo(uint32 a) constant returns(uint b) { return a * 4; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -286,11 +297,13 @@ BOOST_AUTO_TEST_CASE(const_function)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(events)
|
BOOST_AUTO_TEST_CASE(events)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint a) returns(uint d) { return a * 7; }\n"
|
contract test {
|
||||||
" event e1(uint b, address indexed c); \n"
|
function f(uint a) returns(uint d) { return a * 7; }
|
||||||
" event e2(); \n"
|
event e1(uint b, address indexed c);
|
||||||
"}\n";
|
event e2();
|
||||||
|
}
|
||||||
|
)";
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
@ -341,9 +354,11 @@ BOOST_AUTO_TEST_CASE(events)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(events_anonymous)
|
BOOST_AUTO_TEST_CASE(events_anonymous)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" event e() anonymous; \n"
|
contract test {
|
||||||
"}\n";
|
event e() anonymous;
|
||||||
|
}
|
||||||
|
)";
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "e",
|
"name": "e",
|
||||||
@ -359,15 +374,16 @@ BOOST_AUTO_TEST_CASE(events_anonymous)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(inherited)
|
BOOST_AUTO_TEST_CASE(inherited)
|
||||||
{
|
{
|
||||||
char const* sourceCode =
|
char const* sourceCode = R"(
|
||||||
" contract Base { \n"
|
contract Base {
|
||||||
" function baseFunction(uint p) returns (uint i) { return p; } \n"
|
function baseFunction(uint p) returns (uint i) { return p; }
|
||||||
" event baseEvent(bytes32 indexed evtArgBase); \n"
|
event baseEvent(bytes32 indexed evtArgBase);
|
||||||
" } \n"
|
}
|
||||||
" contract Derived is Base { \n"
|
contract Derived is Base {
|
||||||
" function derivedFunction(bytes32 p) returns (bytes32 i) { return p; } \n"
|
function derivedFunction(bytes32 p) returns (bytes32 i) { return p; }
|
||||||
" event derivedEvent(uint indexed evtArgDerived); \n"
|
event derivedEvent(uint indexed evtArgDerived);
|
||||||
" }";
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -431,13 +447,14 @@ BOOST_AUTO_TEST_CASE(inherited)
|
|||||||
BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
|
BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f(uint, uint k) returns(uint ret_k, uint ret_g){
|
function f(uint, uint k) returns(uint ret_k, uint ret_g) {
|
||||||
uint g = 8;
|
uint g = 8;
|
||||||
ret_k = k;
|
ret_k = k;
|
||||||
ret_g = g;
|
ret_g = g;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})";
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -475,10 +492,11 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function f(uint k) returns(uint){
|
function f(uint k) returns(uint) {
|
||||||
return k;
|
return k;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})";
|
)";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
@ -542,7 +560,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
|
|||||||
contract test {
|
contract test {
|
||||||
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
|
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
|
||||||
function test(ActionChoices param) {}
|
function test(ActionChoices param) {}
|
||||||
function ret() returns(ActionChoices){
|
function ret() returns(ActionChoices) {
|
||||||
ActionChoices action = ActionChoices.GoLeft;
|
ActionChoices action = ActionChoices.GoLeft;
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
@ -612,7 +630,7 @@ BOOST_AUTO_TEST_CASE(library_function)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
library test {
|
library test {
|
||||||
struct StructType { uint a; }
|
struct StructType { uint a; }
|
||||||
function f(StructType storage b, uint[] storage c, test d) returns (uint[] e, StructType storage f){}
|
function f(StructType storage b, uint[] storage c, test d) returns (uint[] e, StructType storage f) {}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
@ -168,9 +168,11 @@ BOOST_AUTO_TEST_SUITE(SolidityExpressionCompiler)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(literal_true)
|
BOOST_AUTO_TEST_CASE(literal_true)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { var x = true; }"
|
contract test {
|
||||||
"}\n";
|
function f() { var x = true; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH1), 0x1});
|
bytes expectation({byte(Instruction::PUSH1), 0x1});
|
||||||
@ -179,9 +181,11 @@ BOOST_AUTO_TEST_CASE(literal_true)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(literal_false)
|
BOOST_AUTO_TEST_CASE(literal_false)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { var x = false; }"
|
contract test {
|
||||||
"}\n";
|
function f() { var x = false; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH1), 0x0});
|
bytes expectation({byte(Instruction::PUSH1), 0x0});
|
||||||
@ -190,9 +194,11 @@ BOOST_AUTO_TEST_CASE(literal_false)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(int_literal)
|
BOOST_AUTO_TEST_CASE(int_literal)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { var x = 0x12345678901234567890; }"
|
contract test {
|
||||||
"}\n";
|
function f() { var x = 0x12345678901234567890; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH10), 0x12, 0x34, 0x56, 0x78, 0x90,
|
bytes expectation({byte(Instruction::PUSH10), 0x12, 0x34, 0x56, 0x78, 0x90,
|
||||||
@ -204,11 +210,11 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function test ()
|
function test () {
|
||||||
{
|
|
||||||
var x = 1 wei;
|
var x = 1 wei;
|
||||||
}
|
}
|
||||||
})";
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH1), 0x1});
|
bytes expectation({byte(Instruction::PUSH1), 0x1});
|
||||||
@ -219,11 +225,11 @@ BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function test ()
|
function test () {
|
||||||
{
|
|
||||||
var x = 1 szabo;
|
var x = 1 szabo;
|
||||||
}
|
}
|
||||||
})";
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH5), 0xe8, 0xd4, 0xa5, 0x10, 0x00});
|
bytes expectation({byte(Instruction::PUSH5), 0xe8, 0xd4, 0xa5, 0x10, 0x00});
|
||||||
@ -249,11 +255,11 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
function test ()
|
function test () {
|
||||||
{
|
|
||||||
var x = 1 ether;
|
var x = 1 ether;
|
||||||
}
|
}
|
||||||
})";
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH8), 0xd, 0xe0, 0xb6, 0xb3, 0xa7, 0x64, 0x00, 0x00});
|
bytes expectation({byte(Instruction::PUSH8), 0xd, 0xe0, 0xb6, 0xb3, 0xa7, 0x64, 0x00, 0x00});
|
||||||
@ -262,9 +268,11 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(comparison)
|
BOOST_AUTO_TEST_CASE(comparison)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { var x = (0x10aa < 0x11aa) != true; }"
|
contract test {
|
||||||
"}\n";
|
function f() { var x = (0x10aa < 0x11aa) != true; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH1), 0x1, byte(Instruction::ISZERO), byte(Instruction::ISZERO),
|
bytes expectation({byte(Instruction::PUSH1), 0x1, byte(Instruction::ISZERO), byte(Instruction::ISZERO),
|
||||||
@ -278,9 +286,11 @@ BOOST_AUTO_TEST_CASE(comparison)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(short_circuiting)
|
BOOST_AUTO_TEST_CASE(short_circuiting)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { var x = true != (4 <= 8 + 10 || 9 != 2); }"
|
contract test {
|
||||||
"}\n";
|
function f() { var x = true != (4 <= 8 + 10 || 9 != 2); }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH1), 0x12, // 8 + 10
|
bytes expectation({byte(Instruction::PUSH1), 0x12, // 8 + 10
|
||||||
@ -305,9 +315,11 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(arithmetics)
|
BOOST_AUTO_TEST_CASE(arithmetics)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint y) { var x = ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); }"
|
contract test {
|
||||||
"}\n";
|
function f(uint y) { var x = ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
|
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
|
||||||
bytes expectation({byte(Instruction::PUSH1), 0x1,
|
bytes expectation({byte(Instruction::PUSH1), 0x1,
|
||||||
byte(Instruction::PUSH1), 0x2,
|
byte(Instruction::PUSH1), 0x2,
|
||||||
@ -339,9 +351,11 @@ BOOST_AUTO_TEST_CASE(arithmetics)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(unary_operators)
|
BOOST_AUTO_TEST_CASE(unary_operators)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(int y) { var x = !(~+- y == 2); }"
|
contract test {
|
||||||
"}\n";
|
function f(int y) { var x = !(~+- y == 2); }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
|
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
|
||||||
|
|
||||||
bytes expectation({byte(Instruction::PUSH1), 0x2,
|
bytes expectation({byte(Instruction::PUSH1), 0x2,
|
||||||
@ -356,9 +370,11 @@ BOOST_AUTO_TEST_CASE(unary_operators)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(unary_inc_dec)
|
BOOST_AUTO_TEST_CASE(unary_inc_dec)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint a) { var x = --a ^ (a-- ^ (++a ^ a++)); }"
|
contract test {
|
||||||
"}\n";
|
function f(uint a) { var x = --a ^ (a-- ^ (++a ^ a++)); }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}});
|
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}});
|
||||||
|
|
||||||
// Stack: a, x
|
// Stack: a, x
|
||||||
@ -406,9 +422,11 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(assignment)
|
BOOST_AUTO_TEST_CASE(assignment)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f(uint a, uint b) { (a += b) * 2; }"
|
contract test {
|
||||||
"}\n";
|
function f(uint a, uint b) { (a += b) * 2; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}});
|
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}});
|
||||||
|
|
||||||
// Stack: a, b
|
// Stack: a, b
|
||||||
@ -427,9 +445,11 @@ BOOST_AUTO_TEST_CASE(assignment)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(negative_literals_8bits)
|
BOOST_AUTO_TEST_CASE(negative_literals_8bits)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { int8 x = -0x80; }\n"
|
contract test {
|
||||||
"}\n";
|
function f() { int8 x = -0x80; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation(bytes({byte(Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80));
|
bytes expectation(bytes({byte(Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80));
|
||||||
@ -438,9 +458,11 @@ BOOST_AUTO_TEST_CASE(negative_literals_8bits)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(negative_literals_16bits)
|
BOOST_AUTO_TEST_CASE(negative_literals_16bits)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { int64 x = ~0xabc; }\n"
|
contract test {
|
||||||
"}\n";
|
function f() { int64 x = ~0xabc; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation(bytes({byte(Instruction::PUSH32)}) + bytes(30, 0xff) + bytes{0xf5, 0x43});
|
bytes expectation(bytes({byte(Instruction::PUSH32)}) + bytes(30, 0xff) + bytes{0xf5, 0x43});
|
||||||
@ -451,9 +473,11 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals)
|
|||||||
{
|
{
|
||||||
// first literal itself is too large for 256 bits but it fits after all constant operations
|
// first literal itself is too large for 256 bits but it fits after all constant operations
|
||||||
// have been applied
|
// have been applied
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }\n"
|
contract test {
|
||||||
"}\n";
|
function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode);
|
bytes code = compileFirstExpression(sourceCode);
|
||||||
|
|
||||||
bytes expectation(bytes({byte(Instruction::PUSH1), 0xbf}));
|
bytes expectation(bytes({byte(Instruction::PUSH1), 0xbf}));
|
||||||
@ -462,11 +486,13 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(blockhash)
|
BOOST_AUTO_TEST_CASE(blockhash)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function f() {\n"
|
contract test {
|
||||||
" block.blockhash(3);\n"
|
function f() {
|
||||||
" }\n"
|
block.blockhash(3);
|
||||||
"}\n";
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
bytes code = compileFirstExpression(sourceCode, {}, {},
|
bytes code = compileFirstExpression(sourceCode, {}, {},
|
||||||
{make_shared<MagicVariableDeclaration>("block", make_shared<MagicType>(MagicType::Kind::Block))});
|
{make_shared<MagicVariableDeclaration>("block", make_shared<MagicType>(MagicType::Kind::Block))});
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -76,10 +76,12 @@ BOOST_FIXTURE_TEST_SUITE(SolidityNatspecJSON, DocumentationChecker)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(user_basic_test)
|
BOOST_AUTO_TEST_CASE(user_basic_test)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @notice Multiplies `a` by 7\n"
|
contract test {
|
||||||
" function mul(uint a) returns(uint d) { return a * 7; }\n"
|
/// @notice Multiplies `a` by 7
|
||||||
"}\n";
|
function mul(uint a) returns(uint d) { return a * 7; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -91,11 +93,13 @@ BOOST_AUTO_TEST_CASE(user_basic_test)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
|
BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @notice Multiplies `a` by 7\n"
|
contract test {
|
||||||
" /// @dev Multiplies a number by 7\n"
|
/// @notice Multiplies `a` by 7
|
||||||
" function mul(uint a) returns(uint d) { return a * 7; }\n"
|
/// @dev Multiplies a number by 7
|
||||||
"}\n";
|
function mul(uint a) returns(uint d) { return a * 7; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* devNatspec = "{"
|
char const* devNatspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -116,14 +120,15 @@ BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(user_multiline_comment)
|
BOOST_AUTO_TEST_CASE(user_multiline_comment)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @notice Multiplies `a` by 7\n"
|
contract test {
|
||||||
" /// and then adds `b`\n"
|
/// @notice Multiplies `a` by 7
|
||||||
" function mul_and_add(uint a, uint256 b) returns(uint256 d)\n"
|
/// and then adds `b`
|
||||||
" {\n"
|
function mul_and_add(uint a, uint256 b) returns(uint256 d) {
|
||||||
" return (a * 7) + b;\n"
|
return (a * 7) + b;
|
||||||
" }\n"
|
}
|
||||||
"}\n";
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -135,24 +140,24 @@ BOOST_AUTO_TEST_CASE(user_multiline_comment)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(user_multiple_functions)
|
BOOST_AUTO_TEST_CASE(user_multiple_functions)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @notice Multiplies `a` by 7 and then adds `b`\n"
|
contract test {
|
||||||
" function mul_and_add(uint a, uint256 b) returns(uint256 d)\n"
|
/// @notice Multiplies `a` by 7 and then adds `b`
|
||||||
" {\n"
|
function mul_and_add(uint a, uint256 b) returns(uint256 d) {
|
||||||
" return (a * 7) + b;\n"
|
return (a * 7) + b;
|
||||||
" }\n"
|
}
|
||||||
"\n"
|
|
||||||
" /// @notice Divides `input` by `div`\n"
|
/// @notice Divides `input` by `div`
|
||||||
" function divide(uint input, uint div) returns(uint d)\n"
|
function divide(uint input, uint div) returns(uint d) {
|
||||||
" {\n"
|
return input / div;
|
||||||
" return input / div;\n"
|
}
|
||||||
" }\n"
|
|
||||||
" /// @notice Subtracts 3 from `input`\n"
|
/// @notice Subtracts 3 from `input`
|
||||||
" function sub(int input) returns(int d)\n"
|
function sub(int input) returns(int d) {
|
||||||
" {\n"
|
return input - 3;
|
||||||
" return input - 3;\n"
|
}
|
||||||
" }\n"
|
}
|
||||||
"}\n";
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -166,8 +171,9 @@ BOOST_AUTO_TEST_CASE(user_multiple_functions)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(user_empty_contract)
|
BOOST_AUTO_TEST_CASE(user_empty_contract)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
"}\n";
|
contract test { }
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{\"methods\":{} }";
|
char const* natspec = "{\"methods\":{} }";
|
||||||
|
|
||||||
@ -176,13 +182,16 @@ BOOST_AUTO_TEST_CASE(user_empty_contract)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
|
BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" function mul(uint a) returns(uint d) { return a * 7; }\n"
|
contract test {
|
||||||
" function sub(int input) returns(int d)\n"
|
function mul(uint a) returns(uint d) {
|
||||||
" {\n"
|
return a * 7;
|
||||||
" return input - 3;\n"
|
}
|
||||||
" }\n"
|
function sub(int input) returns(int d) {
|
||||||
"}\n";
|
return input - 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* devNatspec = "{\"methods\":{}}";
|
char const* devNatspec = "{\"methods\":{}}";
|
||||||
char const* userNatspec = "{\"methods\":{}}";
|
char const* userNatspec = "{\"methods\":{}}";
|
||||||
@ -193,13 +202,15 @@ BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
|
BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev\n"
|
contract test {
|
||||||
" /// Multiplies a number by 7 and adds second parameter\n"
|
/// @dev
|
||||||
" /// @param a Documentation for the first parameter\n"
|
/// Multiplies a number by 7 and adds second parameter
|
||||||
" /// @param second Documentation for the second parameter\n"
|
/// @param a Documentation for the first parameter
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @param second Documentation for the second parameter
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -217,12 +228,14 @@ BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_multiple_params)
|
BOOST_AUTO_TEST_CASE(dev_multiple_params)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Multiplies a number by 7 and adds second parameter\n"
|
contract test {
|
||||||
" /// @param a Documentation for the first parameter\n"
|
/// @dev Multiplies a number by 7 and adds second parameter
|
||||||
" /// @param second Documentation for the second parameter\n"
|
/// @param a Documentation for the first parameter
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @param second Documentation for the second parameter
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -240,13 +253,15 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
|
BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Multiplies a number by 7 and adds second parameter\n"
|
contract test {
|
||||||
" /// @param a Documentation for the first parameter starts here.\n"
|
/// @dev Multiplies a number by 7 and adds second parameter
|
||||||
" /// Since it's a really complicated parameter we need 2 lines\n"
|
/// @param a Documentation for the first parameter starts here.
|
||||||
" /// @param second Documentation for the second parameter\n"
|
/// Since it's a really complicated parameter we need 2 lines
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @param second Documentation for the second parameter
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -264,26 +279,27 @@ BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_multiple_functions)
|
BOOST_AUTO_TEST_CASE(dev_multiple_functions)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Multiplies a number by 7 and adds second parameter\n"
|
contract test {
|
||||||
" /// @param a Documentation for the first parameter\n"
|
/// @dev Multiplies a number by 7 and adds second parameter
|
||||||
" /// @param second Documentation for the second parameter\n"
|
/// @param a Documentation for the first parameter
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @param second Documentation for the second parameter
|
||||||
" \n"
|
function mul(uint a, uint second) returns(uint d) {
|
||||||
" /// @dev Divides 2 numbers\n"
|
return a * 7 + second;
|
||||||
" /// @param input Documentation for the input parameter\n"
|
}
|
||||||
" /// @param div Documentation for the div parameter\n"
|
/// @dev Divides 2 numbers
|
||||||
" function divide(uint input, uint div) returns(uint d)\n"
|
/// @param input Documentation for the input parameter
|
||||||
" {\n"
|
/// @param div Documentation for the div parameter
|
||||||
" return input / div;\n"
|
function divide(uint input, uint div) returns(uint d) {
|
||||||
" }\n"
|
return input / div;
|
||||||
" /// @dev Subtracts 3 from `input`\n"
|
}
|
||||||
" /// @param input Documentation for the input parameter\n"
|
/// @dev Subtracts 3 from `input`
|
||||||
" function sub(int input) returns(int d)\n"
|
/// @param input Documentation for the input parameter
|
||||||
" {\n"
|
function sub(int input) returns(int d) {
|
||||||
" return input - 3;\n"
|
return input - 3;
|
||||||
" }\n"
|
}
|
||||||
"}\n";
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -314,14 +330,16 @@ BOOST_AUTO_TEST_CASE(dev_multiple_functions)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_return)
|
BOOST_AUTO_TEST_CASE(dev_return)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Multiplies a number by 7 and adds second parameter\n"
|
contract test {
|
||||||
" /// @param a Documentation for the first parameter starts here.\n"
|
/// @dev Multiplies a number by 7 and adds second parameter
|
||||||
" /// Since it's a really complicated parameter we need 2 lines\n"
|
/// @param a Documentation for the first parameter starts here.
|
||||||
" /// @param second Documentation for the second parameter\n"
|
/// Since it's a really complicated parameter we need 2 lines
|
||||||
" /// @return The result of the multiplication\n"
|
/// @param second Documentation for the second parameter
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @return The result of the multiplication
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -339,15 +357,19 @@ BOOST_AUTO_TEST_CASE(dev_return)
|
|||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
|
BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Multiplies a number by 7 and adds second parameter\n"
|
contract test {
|
||||||
" /// @param a Documentation for the first parameter starts here.\n"
|
/// @dev Multiplies a number by 7 and adds second parameter
|
||||||
" /// Since it's a really complicated parameter we need 2 lines\n"
|
/// @param a Documentation for the first parameter starts here.
|
||||||
" /// @param second Documentation for the second parameter\n"
|
/// Since it's a really complicated parameter we need 2 lines
|
||||||
" /// @return\n"
|
/// @param second Documentation for the second parameter
|
||||||
" /// The result of the multiplication\n"
|
/// @return
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// The result of the multiplication
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) {
|
||||||
|
return a * 7 + second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -367,15 +389,19 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_multiline_return)
|
BOOST_AUTO_TEST_CASE(dev_multiline_return)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Multiplies a number by 7 and adds second parameter\n"
|
contract test {
|
||||||
" /// @param a Documentation for the first parameter starts here.\n"
|
/// @dev Multiplies a number by 7 and adds second parameter
|
||||||
" /// Since it's a really complicated parameter we need 2 lines\n"
|
/// @param a Documentation for the first parameter starts here.
|
||||||
" /// @param second Documentation for the second parameter\n"
|
/// Since it's a really complicated parameter we need 2 lines
|
||||||
" /// @return The result of the multiplication\n"
|
/// @param second Documentation for the second parameter
|
||||||
" /// and cookies with nutella\n"
|
/// @return The result of the multiplication
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// and cookies with nutella
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) {
|
||||||
|
return a * 7 + second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -394,17 +420,21 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_multiline_comment)
|
BOOST_AUTO_TEST_CASE(dev_multiline_comment)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /**\n"
|
contract test {
|
||||||
" * @dev Multiplies a number by 7 and adds second parameter\n"
|
/**
|
||||||
" * @param a Documentation for the first parameter starts here.\n"
|
* @dev Multiplies a number by 7 and adds second parameter
|
||||||
" * Since it's a really complicated parameter we need 2 lines\n"
|
* @param a Documentation for the first parameter starts here.
|
||||||
" * @param second Documentation for the second parameter\n"
|
* Since it's a really complicated parameter we need 2 lines
|
||||||
" * @return The result of the multiplication\n"
|
* @param second Documentation for the second parameter
|
||||||
" * and cookies with nutella\n"
|
* @return The result of the multiplication
|
||||||
" */"
|
* and cookies with nutella
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
*/
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) {
|
||||||
|
return a * 7 + second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
"\"methods\":{"
|
"\"methods\":{"
|
||||||
@ -423,10 +453,12 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
|
BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Mul function\n"
|
contract test {
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @dev Mul function
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
" \"methods\":{"
|
" \"methods\":{"
|
||||||
@ -441,12 +473,14 @@ BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_contract_doc)
|
BOOST_AUTO_TEST_CASE(dev_contract_doc)
|
||||||
{
|
{
|
||||||
char const* sourceCode = " /// @author Lefteris\n"
|
char const* sourceCode = R"(
|
||||||
" /// @title Just a test contract\n"
|
/// @author Lefteris
|
||||||
"contract test {\n"
|
/// @title Just a test contract
|
||||||
" /// @dev Mul function\n"
|
contract test {
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @dev Mul function
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
" \"author\": \"Lefteris\","
|
" \"author\": \"Lefteris\","
|
||||||
@ -463,13 +497,15 @@ BOOST_AUTO_TEST_CASE(dev_contract_doc)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_author_at_function)
|
BOOST_AUTO_TEST_CASE(dev_author_at_function)
|
||||||
{
|
{
|
||||||
char const* sourceCode = " /// @author Lefteris\n"
|
char const* sourceCode = R"(
|
||||||
" /// @title Just a test contract\n"
|
/// @author Lefteris
|
||||||
"contract test {\n"
|
/// @title Just a test contract
|
||||||
" /// @dev Mul function\n"
|
contract test {
|
||||||
" /// @author John Doe\n"
|
/// @dev Mul function
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @author John Doe
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
char const* natspec = "{"
|
char const* natspec = "{"
|
||||||
" \"author\": \"Lefteris\","
|
" \"author\": \"Lefteris\","
|
||||||
@ -549,25 +585,29 @@ BOOST_AUTO_TEST_CASE(empty_comment)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_title_at_function_error)
|
BOOST_AUTO_TEST_CASE(dev_title_at_function_error)
|
||||||
{
|
{
|
||||||
char const* sourceCode = " /// @author Lefteris\n"
|
char const* sourceCode = R"(
|
||||||
" /// @title Just a test contract\n"
|
/// @author Lefteris
|
||||||
"contract test {\n"
|
/// @title Just a test contract
|
||||||
" /// @dev Mul function\n"
|
contract test {
|
||||||
" /// @title I really should not be here\n"
|
/// @dev Mul function
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @title I really should not be here
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
expectNatspecError(sourceCode);
|
expectNatspecError(sourceCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(dev_documenting_nonexistent_param)
|
BOOST_AUTO_TEST_CASE(dev_documenting_nonexistent_param)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = R"(
|
||||||
" /// @dev Multiplies a number by 7 and adds second parameter\n"
|
contract test {
|
||||||
" /// @param a Documentation for the first parameter\n"
|
/// @dev Multiplies a number by 7 and adds second parameter
|
||||||
" /// @param not_existing Documentation for the second parameter\n"
|
/// @param a Documentation for the first parameter
|
||||||
" function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
|
/// @param not_existing Documentation for the second parameter
|
||||||
"}\n";
|
function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
expectNatspecError(sourceCode);
|
expectNatspecError(sourceCode);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user