aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/ASTJSON.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-14 20:32:27 +0800
committerGitHub <noreply@github.com>2017-06-14 20:32:27 +0800
commit21aafaa70439e41da1c9eb6b37d08707d90b35f0 (patch)
tree6a8a1a585950f7987b1f2630e1f23c16c05d5cce /test/libsolidity/ASTJSON.cpp
parente232a105f036e40c9da5c3ce051c5ebd4236b558 (diff)
parent83f0e00900a51c03cc7d8c088bbac0c4814a9e49 (diff)
downloaddexon-solidity-21aafaa70439e41da1c9eb6b37d08707d90b35f0.tar.gz
dexon-solidity-21aafaa70439e41da1c9eb6b37d08707d90b35f0.tar.zst
dexon-solidity-21aafaa70439e41da1c9eb6b37d08707d90b35f0.zip
Merge pull request #2331 from ethereum/ASTDocumentationEntry
documentation field added to ContractDefinition-Node
Diffstat (limited to 'test/libsolidity/ASTJSON.cpp')
-rw-r--r--test/libsolidity/ASTJSON.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
index df7fac51..4fb4f20c 100644
--- a/test/libsolidity/ASTJSON.cpp
+++ b/test/libsolidity/ASTJSON.cpp
@@ -228,6 +228,36 @@ BOOST_AUTO_TEST_CASE(function_type)
BOOST_CHECK_EQUAL(funType["attributes"]["visibility"], "external");
}
+BOOST_AUTO_TEST_CASE(documentation)
+{
+ CompilerStack c;
+ c.addSource("a", "/**This contract is empty*/ contract C {}");
+ c.addSource("b",
+ "/**This contract is empty"
+ " and has a line-breaking comment.*/"
+ "contract C {}"
+ );
+ c.parseAndAnalyze();
+ map<string, unsigned> sourceIndices;
+ sourceIndices["a"] = 0;
+ sourceIndices["b"] = 1;
+ Json::Value astJsonA = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
+ Json::Value documentationA = astJsonA["children"][0]["attributes"]["documentation"];
+ BOOST_CHECK_EQUAL(documentationA, "This contract is empty");
+ Json::Value astJsonB = ASTJsonConverter(true, sourceIndices).toJson(c.ast("b"));
+ Json::Value documentationB = astJsonB["children"][0]["attributes"]["documentation"];
+ BOOST_CHECK_EQUAL(documentationB, "This contract is empty and has a line-breaking comment.");
+ //same tests for non-legacy mode
+ astJsonA = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
+ documentationA = astJsonA["nodes"][0]["documentation"];
+ BOOST_CHECK_EQUAL(documentationA, "This contract is empty");
+ astJsonB = ASTJsonConverter(false, sourceIndices).toJson(c.ast("b"));
+ documentationB = astJsonB["nodes"][0]["documentation"];
+ BOOST_CHECK_EQUAL(documentationB, "This contract is empty and has a line-breaking comment.");
+
+}
+
+
BOOST_AUTO_TEST_SUITE_END()
}