diff options
author | chriseth <chris@ethereum.org> | 2018-02-19 23:46:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-19 23:46:27 +0800 |
commit | dcfbcddd52cb02897a6d1748ad67a0b41d159cca (patch) | |
tree | 96eea930101bf1fa1bac0269a29082103a62e4d0 /test | |
parent | 839acafb9590c24da9446fc66f8a26939210eeb3 (diff) | |
parent | 7530592a583dcb1a02bc5c8a01bde89a399a448d (diff) | |
download | dexon-solidity-dcfbcddd52cb02897a6d1748ad67a0b41d159cca.tar dexon-solidity-dcfbcddd52cb02897a6d1748ad67a0b41d159cca.tar.gz dexon-solidity-dcfbcddd52cb02897a6d1748ad67a0b41d159cca.tar.bz2 dexon-solidity-dcfbcddd52cb02897a6d1748ad67a0b41d159cca.tar.lz dexon-solidity-dcfbcddd52cb02897a6d1748ad67a0b41d159cca.tar.xz dexon-solidity-dcfbcddd52cb02897a6d1748ad67a0b41d159cca.tar.zst dexon-solidity-dcfbcddd52cb02897a6d1748ad67a0b41d159cca.zip |
Merge pull request #3540 from ealmansi/fix/add-doc-prop-3537
Added JSON property 'documentation' to Function, Event, and Modifier defs.
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/ASTJSON.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp index 31165922..a165f7a9 100644 --- a/test/libsolidity/ASTJSON.cpp +++ b/test/libsolidity/ASTJSON.cpp @@ -237,16 +237,31 @@ BOOST_AUTO_TEST_CASE(documentation) " and has a line-breaking comment.*/" "contract C {}" ); + c.addSource("c", + "contract C {" + " /** Some comment on Evt.*/ event Evt();" + " /** Some comment on mod.*/ modifier mod() { _; }" + " /** Some comment on fn.*/ function fn() public {}" + "}" + ); c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 0; sourceIndices["b"] = 1; + sourceIndices["c"] = 2; 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."); + Json::Value astJsonC = ASTJsonConverter(true, sourceIndices).toJson(c.ast("c")); + Json::Value documentationC0 = astJsonC["children"][0]["children"][0]["attributes"]["documentation"]; + Json::Value documentationC1 = astJsonC["children"][0]["children"][1]["attributes"]["documentation"]; + Json::Value documentationC2 = astJsonC["children"][0]["children"][2]["attributes"]["documentation"]; + BOOST_CHECK_EQUAL(documentationC0, "Some comment on Evt."); + BOOST_CHECK_EQUAL(documentationC1, "Some comment on mod."); + BOOST_CHECK_EQUAL(documentationC2, "Some comment on fn."); //same tests for non-legacy mode astJsonA = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a")); documentationA = astJsonA["nodes"][0]["documentation"]; @@ -254,7 +269,13 @@ BOOST_AUTO_TEST_CASE(documentation) 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."); - + astJsonC = ASTJsonConverter(false, sourceIndices).toJson(c.ast("c")); + documentationC0 = astJsonC["nodes"][0]["nodes"][0]["documentation"]; + documentationC1 = astJsonC["nodes"][0]["nodes"][1]["documentation"]; + documentationC2 = astJsonC["nodes"][0]["nodes"][2]["documentation"]; + BOOST_CHECK_EQUAL(documentationC0, "Some comment on Evt."); + BOOST_CHECK_EQUAL(documentationC1, "Some comment on mod."); + BOOST_CHECK_EQUAL(documentationC2, "Some comment on fn."); } |