From b011ddfae351c5a4883c88898390ea863be9a410 Mon Sep 17 00:00:00 2001 From: djudjuu Date: Tue, 30 May 2017 19:25:54 +0200 Subject: adjusted test-cases --- test/libsolidity/JSONCompiler.cpp | 2 +- test/libsolidity/StandardCompiler.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/libsolidity/JSONCompiler.cpp b/test/libsolidity/JSONCompiler.cpp index 6aec59ab..e920c73c 100644 --- a/test/libsolidity/JSONCompiler.cpp +++ b/test/libsolidity/JSONCompiler.cpp @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(dev::jsonCompactPrint(result["sources"]["fileA"]["AST"]) == "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}}," "\"children\":[{\"attributes\":{\"baseContracts\":[null],\"contractDependencies\":[null]," - "\"contractKind\":\"contract\",\"fullyImplemented\":true,\"linearizedBaseContracts\":[1]," + "\"contractKind\":\"contract\",\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1]," "\"name\":\"A\",\"nodes\":[null],\"scope\":2},\"id\":1,\"name\":\"ContractDefinition\"," "\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}"); } diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 050ca500..92bb471b 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(dev::jsonCompactPrint(result["sources"]["fileA"]["legacyAST"]) == "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}},\"children\":" "[{\"attributes\":{\"baseContracts\":[null],\"contractDependencies\":[null],\"contractKind\":\"contract\"," - "\"fullyImplemented\":true,\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nodes\":[null],\"scope\":2}," + "\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nodes\":[null],\"scope\":2}," "\"id\":1,\"name\":\"ContractDefinition\",\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}"); } -- cgit v1.2.3 From ebdebc7c12d152bcf9c96274ecf7dea2e46e2541 Mon Sep 17 00:00:00 2001 From: djudjuu Date: Mon, 5 Jun 2017 15:04:15 +0200 Subject: new test case and indentation fix --- test/libsolidity/ASTJSON.cpp | 22 ++++++++++++++++++++++ test/libsolidity/JSONCompiler.cpp | 8 ++++---- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp index 8a790347..4476f1ed 100644 --- a/test/libsolidity/ASTJSON.cpp +++ b/test/libsolidity/ASTJSON.cpp @@ -228,6 +228,28 @@ 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 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."); +} + + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/JSONCompiler.cpp b/test/libsolidity/JSONCompiler.cpp index e920c73c..f5154395 100644 --- a/test/libsolidity/JSONCompiler.cpp +++ b/test/libsolidity/JSONCompiler.cpp @@ -90,11 +90,11 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(result["sources"]["fileA"].isObject()); BOOST_CHECK(result["sources"]["fileA"]["AST"].isObject()); BOOST_CHECK(dev::jsonCompactPrint(result["sources"]["fileA"]["AST"]) == - "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}}," - "\"children\":[{\"attributes\":{\"baseContracts\":[null],\"contractDependencies\":[null]," + "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}}," + "\"children\":[{\"attributes\":{\"baseContracts\":[null],\"contractDependencies\":[null]," "\"contractKind\":\"contract\",\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1]," - "\"name\":\"A\",\"nodes\":[null],\"scope\":2},\"id\":1,\"name\":\"ContractDefinition\"," - "\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}"); + "\"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() -- cgit v1.2.3 From 83f0e00900a51c03cc7d8c088bbac0c4814a9e49 Mon Sep 17 00:00:00 2001 From: djudjuu Date: Wed, 7 Jun 2017 15:52:44 +0200 Subject: tests for non-legacy mode --- test/libsolidity/ASTJSON.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp index 4476f1ed..e9e00b13 100644 --- a/test/libsolidity/ASTJSON.cpp +++ b/test/libsolidity/ASTJSON.cpp @@ -247,6 +247,14 @@ BOOST_AUTO_TEST_CASE(documentation) 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."); + } -- cgit v1.2.3