Add ast json converter for UsingForDirective

This commit is contained in:
Alex Sinyagin
2016-08-18 12:29:59 +00:00
parent 9e7fc12463
commit 40ca2c9e97
3 changed files with 31 additions and 1 deletions
+17
View File
@@ -76,6 +76,23 @@ BOOST_AUTO_TEST_CASE(inheritance_specifier)
BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["children"][0]["attributes"]["name"], "C1");
}
BOOST_AUTO_TEST_CASE(using_for_directive)
{
CompilerStack c;
c.addSource("a", "library L {} contract C { using L for uint; }");
c.parse();
map<string, unsigned> sourceIndices;
sourceIndices["a"] = 1;
Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json();
Json::Value usingFor = astJson["children"][1]["children"][0];
BOOST_CHECK_EQUAL(usingFor["name"], "UsingFor");
BOOST_CHECK_EQUAL(usingFor["src"], "26:17:1");
BOOST_CHECK_EQUAL(usingFor["children"][0]["name"], "UserDefinedTypeName");
BOOST_CHECK_EQUAL(usingFor["children"][0]["attributes"]["name"], "L");
BOOST_CHECK_EQUAL(usingFor["children"][1]["name"], "ElementaryTypeName");
BOOST_CHECK_EQUAL(usingFor["children"][1]["attributes"]["name"], "uint");
}
BOOST_AUTO_TEST_SUITE_END()
}