Merge pull request #12552 from ethereum/missing-bracket

Add missing bracket in test
This commit is contained in:
Daniel Kirchner 2022-01-19 16:07:41 +01:00 committed by GitHub
commit c3c5937bd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,7 +56,8 @@ public:
else else
generatedDocumentation = m_compilerStack.natspecDev(_contractName); generatedDocumentation = m_compilerStack.natspecDev(_contractName);
Json::Value expectedDocumentation; Json::Value expectedDocumentation;
util::jsonParseStrict(_expectedDocumentationString, expectedDocumentation); std::string parseError;
BOOST_REQUIRE_MESSAGE(util::jsonParseStrict(_expectedDocumentationString, expectedDocumentation, &parseError), parseError);
expectedDocumentation["version"] = Json::Value(Natspec::c_natspecVersion); expectedDocumentation["version"] = Json::Value(Natspec::c_natspecVersion);
expectedDocumentation["kind"] = Json::Value(_userDocumentation ? "user" : "dev"); expectedDocumentation["kind"] = Json::Value(_userDocumentation ? "user" : "dev");
@ -118,7 +119,8 @@ BOOST_AUTO_TEST_CASE(user_newline_break)
char const* natspec = R"ABCDEF( char const* natspec = R"ABCDEF(
{ {
"methods": { "methods":
{
"f()": "f()":
{ {
"notice": "world" "notice": "world"
@ -146,8 +148,10 @@ BOOST_AUTO_TEST_CASE(user_multiline_empty_lines)
char const* natspec = R"ABCDEF( char const* natspec = R"ABCDEF(
{ {
"methods": { "methods":
"f()": { {
"f()":
{
"notice": "hello world" "notice": "hello world"
} }
} }
@ -185,18 +189,27 @@ BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
} }
)"; )";
char const* devNatspec = "{" char const* devNatspec = R"R(
"\"methods\":{" {
" \"mul(uint256)\":{ \n" "methods":
" \"details\": \"Multiplies a number by 7\"\n" {
" }\n" "mul(uint256)":
" }\n" {
"}}"; "details": "Multiplies a number by 7"
}
}
})R";
char const* userNatspec = "{" char const* userNatspec = R"R(
"\"methods\":{" {
" \"mul(uint256)\":{ \"notice\": \"Multiplies `a` by 7\"}" "methods":
"}}"; {
"mul(uint256)":
{
"notice": "Multiplies `a` by 7"
}
}
})R";
checkNatspec(sourceCode, "test", devNatspec, false); checkNatspec(sourceCode, "test", devNatspec, false);
checkNatspec(sourceCode, "test", userNatspec, true); checkNatspec(sourceCode, "test", userNatspec, true);
@ -634,9 +647,11 @@ BOOST_AUTO_TEST_CASE(dev_return_no_params)
char const* natspec = R"ABCDEF( char const* natspec = R"ABCDEF(
{ {
"methods": { "methods":
"mul(uint256,uint256)": { {
"returns": { "d": "The result of the multiplication" "mul(uint256,uint256)":
{
"returns": { "d": "The result of the multiplication" }
} }
} }
})ABCDEF"; })ABCDEF";
@ -866,19 +881,24 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
} }
)"; )";
char const* natspec = "{" char const* natspec = R"R({
"\"methods\":{" "methods":
" \"mul(uint256,uint256)\":{ \n" {
" \"details\": \"Multiplies a number by 7 and adds second parameter\",\n" "mul(uint256,uint256)":
" \"params\": {\n" {
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n" "details": "Multiplies a number by 7 and adds second parameter",
" \"second\": \"Documentation for the second parameter\"\n" "params":
" },\n" {
" \"returns\": {\n" "a": "Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines",
" \"d\": \"The result of the multiplication and cookies with nutella\",\n" "second": "Documentation for the second parameter"
" }\n" },
" }\n" "returns":
"}}"; {
"d": "The result of the multiplication and cookies with nutella"
}
}
}
})R";
checkNatspec(sourceCode, "test", natspec, false); checkNatspec(sourceCode, "test", natspec, false);
} }
@ -901,19 +921,25 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
} }
)"; )";
char const* natspec = "{" char const* natspec = R"R(
"\"methods\":{" {
" \"mul(uint256,uint256)\":{ \n" "methods":
" \"details\": \"Multiplies a number by 7 and adds second parameter\",\n" {
" \"params\": {\n" "mul(uint256,uint256)":
" \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n" {
" \"second\": \"Documentation for the second parameter\"\n" "details": "Multiplies a number by 7 and adds second parameter",
" },\n" "params":
" \"returns\": {\n" {
" \"d\": \"The result of the multiplication and cookies with nutella\",\n" "a": "Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines",
" }\n" "second": "Documentation for the second parameter"
" }\n" },
"}}"; "returns":
{
"d": "The result of the multiplication and cookies with nutella"
}
}
}
})R";
checkNatspec(sourceCode, "test", natspec, false); checkNatspec(sourceCode, "test", natspec, false);
} }
@ -1004,13 +1030,14 @@ BOOST_AUTO_TEST_CASE(natspec_notice_without_tag)
char const* natspec = R"ABCDEF( char const* natspec = R"ABCDEF(
{ {
"methods" : { "methods":
"mul(uint256)" : { {
"mul(uint256)":
{
"notice": "I do something awesome" "notice": "I do something awesome"
} }
} }
} })ABCDEF";
)ABCDEF";
checkNatspec(sourceCode, "test", natspec, true); checkNatspec(sourceCode, "test", natspec, true);
} }
@ -1027,8 +1054,10 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag)
char const* natspec = R"ABCDEF( char const* natspec = R"ABCDEF(
{ {
"methods" : { "methods":
"mul(uint256)" : { {
"mul(uint256)":
{
"notice": "I do something awesome which requires two lines to explain" "notice": "I do something awesome which requires two lines to explain"
} }
} }
@ -1135,8 +1164,10 @@ BOOST_AUTO_TEST_CASE(user_constructor)
)"; )";
char const* natspec = R"ABCDEF({ char const* natspec = R"ABCDEF({
"methods": { "methods":
"constructor" : { {
"constructor":
{
"notice": "this is a really nice constructor" "notice": "this is a really nice constructor"
} }
} }
@ -1157,11 +1188,14 @@ BOOST_AUTO_TEST_CASE(user_constructor_and_function)
)"; )";
char const* natspec = R"ABCDEF({ char const* natspec = R"ABCDEF({
"methods" : { "methods":
"mul(uint256,uint256)" : { {
"mul(uint256,uint256)":
{
"notice": "another multiplier" "notice": "another multiplier"
}, },
"constructor" : { "constructor":
{
"notice": "this is a really nice constructor" "notice": "this is a really nice constructor"
} }
} }
@ -1181,9 +1215,12 @@ BOOST_AUTO_TEST_CASE(dev_constructor)
)"; )";
char const *natspec = R"ABCDEF({ char const *natspec = R"ABCDEF({
"methods" : { "methods":
"constructor" : { {
"params" : { "constructor":
{
"params":
{
"a": "the parameter a is really nice and very useful", "a": "the parameter a is really nice and very useful",
"second": "the second parameter is not very useful, it just provides additional confusion" "second": "the second parameter is not very useful, it just provides additional confusion"
} }
@ -1228,19 +1265,25 @@ BOOST_AUTO_TEST_CASE(dev_constructor_and_function)
)"; )";
char const *natspec = R"ABCDEF({ char const *natspec = R"ABCDEF({
"methods" : { "methods":
"mul(uint256,uint256)" : { {
"mul(uint256,uint256)":
{
"details": "Multiplies a number by 7 and adds second parameter", "details": "Multiplies a number by 7 and adds second parameter",
"params" : { "params":
{
"a": "Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines", "a": "Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines",
"second": "Documentation for the second parameter" "second": "Documentation for the second parameter"
}, },
"returns" : { "returns":
{
"d": "The result of the multiplication and cookies with nutella" "d": "The result of the multiplication and cookies with nutella"
} }
}, },
"constructor" : { "constructor":
"params" : { {
"params":
{
"a": "the parameter a is really nice and very useful", "a": "the parameter a is really nice and very useful",
"second": "the second parameter is not very useful, it just provides additional confusion" "second": "the second parameter is not very useful, it just provides additional confusion"
} }
@ -1292,7 +1335,8 @@ BOOST_AUTO_TEST_CASE(slash3_slash3)
)"; )";
char const* natspec = R"ABCDEF({ char const* natspec = R"ABCDEF({
"methods": { "methods":
{
"f()": { "notice": "lorem ipsum" } "f()": { "notice": "lorem ipsum" }
} }
})ABCDEF"; })ABCDEF";
@ -1311,7 +1355,8 @@ BOOST_AUTO_TEST_CASE(slash3_slash4)
)"; )";
char const* natspec = R"ABCDEF({ char const* natspec = R"ABCDEF({
"methods": { "methods":
{
"f()": { "notice": "lorem" } "f()": { "notice": "lorem" }
} }
})ABCDEF"; })ABCDEF";
@ -2295,7 +2340,7 @@ BOOST_AUTO_TEST_CASE(dev_return_name_no_description)
{ {
"returns": "returns":
{ {
"a": "a", "a": "a"
} }
} }
} }
@ -2308,7 +2353,7 @@ BOOST_AUTO_TEST_CASE(dev_return_name_no_description)
{ {
"returns": "returns":
{ {
"b": "a", "b": "a"
} }
} }
} }
@ -2384,7 +2429,8 @@ BOOST_AUTO_TEST_CASE(error_multiple)
char const* devdoc = R"X({ char const* devdoc = R"X({
"methods": {}, "methods": {},
"errors": { "errors":
{
"E(uint256,uint256)": [ "E(uint256,uint256)": [
{ {
"details": "an error.", "details": "an error.",
@ -2465,7 +2511,8 @@ BOOST_AUTO_TEST_CASE(custom_inheritance)
} }
)"; )";
char const* natspecA = R"ABCDEF({ char const* natspecA = R"ABCDEF(
{
"methods": "methods":
{ {
"g(uint256)": "g(uint256)":
@ -2473,8 +2520,9 @@ BOOST_AUTO_TEST_CASE(custom_inheritance)
"custom:since": "2014" "custom:since": "2014"
} }
} }
)ABCDEF"; })ABCDEF";
char const* natspecB = R"ABCDEF({ char const* natspecB = R"ABCDEF(
{
"methods": {} "methods": {}
})ABCDEF"; })ABCDEF";