diff options
author | chriseth <chris@ethereum.org> | 2017-03-21 02:06:17 +0800 |
---|---|---|
committer | djudjuu <julfaber@gmail.com> | 2017-05-17 17:14:33 +0800 |
commit | dea7b864e6bbd80b913abf44dc4748868c5d6975 (patch) | |
tree | ebf81211d3f0a40fdbaf973e1913365942e5fe29 /test | |
parent | 242e43188161d15d36d831652b03095690524c72 (diff) | |
download | dexon-solidity-dea7b864e6bbd80b913abf44dc4748868c5d6975.tar.gz dexon-solidity-dea7b864e6bbd80b913abf44dc4748868c5d6975.tar.zst dexon-solidity-dea7b864e6bbd80b913abf44dc4748868c5d6975.zip |
Compact format for AST-Json with backwards compatibility
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/ASTJSON.cpp | 24 | ||||
-rw-r--r-- | test/libsolidity/StandardCompiler.cpp | 6 |
2 files changed, 16 insertions, 14 deletions
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp index d23815b4..8a790347 100644 --- a/test/libsolidity/ASTJSON.cpp +++ b/test/libsolidity/ASTJSON.cpp @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(smoke_test) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); BOOST_CHECK_EQUAL(astJson["name"], "SourceUnit"); } @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(source_location) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); BOOST_CHECK_EQUAL(astJson["name"], "SourceUnit"); BOOST_CHECK_EQUAL(astJson["children"][0]["name"], "ContractDefinition"); BOOST_CHECK_EQUAL(astJson["children"][0]["children"][0]["name"], "FunctionDefinition"); @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(inheritance_specifier) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); BOOST_CHECK_EQUAL(astJson["children"][1]["attributes"]["name"], "C2"); BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["name"], "InheritanceSpecifier"); BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["src"], "30:2:1"); @@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(using_for_directive) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value usingFor = astJson["children"][1]["children"][0]; BOOST_CHECK_EQUAL(usingFor["name"], "UsingForDirective"); BOOST_CHECK_EQUAL(usingFor["src"], "26:17:1"); @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(enum_value) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value enumDefinition = astJson["children"][0]["children"][0]; BOOST_CHECK_EQUAL(enumDefinition["children"][0]["name"], "EnumValue"); BOOST_CHECK_EQUAL(enumDefinition["children"][0]["attributes"]["name"], "A"); @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(modifier_definition) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value modifier = astJson["children"][0]["children"][0]; BOOST_CHECK_EQUAL(modifier["name"], "ModifierDefinition"); BOOST_CHECK_EQUAL(modifier["attributes"]["name"], "M"); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(modifier_invocation) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value modifier = astJson["children"][0]["children"][1]["children"][2]; BOOST_CHECK_EQUAL(modifier["name"], "ModifierInvocation"); BOOST_CHECK_EQUAL(modifier["src"], "52:4:1"); @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(event_definition) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value event = astJson["children"][0]["children"][0]; BOOST_CHECK_EQUAL(event["name"], "EventDefinition"); BOOST_CHECK_EQUAL(event["attributes"]["name"], "E"); @@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(array_type_name) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value array = astJson["children"][0]["children"][0]["children"][0]; BOOST_CHECK_EQUAL(array["name"], "ArrayTypeName"); BOOST_CHECK_EQUAL(array["src"], "13:6:1"); @@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(placeholder_statement) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value placeholder = astJson["children"][0]["children"][0]["children"][1]["children"][0]; BOOST_CHECK_EQUAL(placeholder["name"], "PlaceholderStatement"); BOOST_CHECK_EQUAL(placeholder["src"], "26:1:1"); @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(non_utf8) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value literal = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][1]; BOOST_CHECK_EQUAL(literal["name"], "Literal"); BOOST_CHECK_EQUAL(literal["attributes"]["hexvalue"], "ff"); @@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(function_type) c.parseAndAnalyze(); map<string, unsigned> sourceIndices; sourceIndices["a"] = 1; - Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a")); Json::Value fun = astJson["children"][0]["children"][0]; BOOST_CHECK_EQUAL(fun["name"], "FunctionDefinition"); Json::Value argument = fun["children"][0]["children"][0]; diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index ec2f69d9..f4d277bd 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -215,8 +215,10 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(result["sources"]["fileA"].isObject()); BOOST_CHECK(result["sources"]["fileA"]["legacyAST"].isObject()); BOOST_CHECK(dev::jsonCompactPrint(result["sources"]["fileA"]["legacyAST"]) == - "{\"children\":[{\"attributes\":{\"fullyImplemented\":true,\"isLibrary\":false,\"linearizedBaseContracts\":[1]," - "\"name\":\"A\"},\"children\":[],\"id\":1,\"name\":\"ContractDefinition\",\"src\":\"0:14:0\"}],\"name\":\"SourceUnit\"}"); + "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}},\"children\":" + "[{\"attributes\":{\"baseContracts\":[null],\"contractDependencies\":[null],\"fullyImplemented\":true," + "\"isLibrary\":false,\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nodes\":[null],\"scope\":2}," + "\"id\":1,\"name\":\"ContractDefinition\",\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}"); } BOOST_AUTO_TEST_SUITE_END() |