aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/TypeChecker.cpp16
-rw-r--r--test/boostTest.cpp7
-rw-r--r--test/libsolidity/ASTJSON.cpp145
-rw-r--r--test/libsolidity/ASTJSON/array_type_name.json76
-rw-r--r--test/libsolidity/ASTJSON/array_type_name.sol1
-rw-r--r--test/libsolidity/ASTJSON/array_type_name_legacy.json89
-rw-r--r--test/libsolidity/ASTJSON/documentation.json182
-rw-r--r--test/libsolidity/ASTJSON/documentation.sol17
-rw-r--r--test/libsolidity/ASTJSON/documentation_legacy.json178
-rw-r--r--test/libsolidity/ASTJSON/enum_value.json57
-rw-r--r--test/libsolidity/ASTJSON/enum_value.sol1
-rw-r--r--test/libsolidity/ASTJSON/enum_value_legacy.json78
-rw-r--r--test/libsolidity/ASTJSON/event_definition.json50
-rw-r--r--test/libsolidity/ASTJSON/event_definition.sol1
-rw-r--r--test/libsolidity/ASTJSON/event_definition_legacy.json74
-rw-r--r--test/libsolidity/ASTJSON/function_type.json230
-rw-r--r--test/libsolidity/ASTJSON/function_type.sol1
-rw-r--r--test/libsolidity/ASTJSON/function_type_legacy.json271
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier.json80
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier.sol1
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier_legacy.json105
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation.json177
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation.sol1
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json209
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier.json183
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier.sol1
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json221
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition.json176
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition.sol1
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition_legacy.json213
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation.json176
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation.sol1
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation_legacy.json213
-rw-r--r--test/libsolidity/ASTJSON/non_utf8.json124
-rw-r--r--test/libsolidity/ASTJSON/non_utf8.sol1
-rw-r--r--test/libsolidity/ASTJSON/non_utf8_legacy.json157
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement.json64
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement.sol1
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement_legacy.json87
-rw-r--r--test/libsolidity/ASTJSON/short_type_name.json128
-rw-r--r--test/libsolidity/ASTJSON/short_type_name.sol1
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_legacy.json164
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref.json140
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref.sol1
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref_legacy.json177
-rw-r--r--test/libsolidity/ASTJSON/smoke.json33
-rw-r--r--test/libsolidity/ASTJSON/smoke.sol1
-rw-r--r--test/libsolidity/ASTJSON/smoke_legacy.json48
-rw-r--r--test/libsolidity/ASTJSON/source_location.json162
-rw-r--r--test/libsolidity/ASTJSON/source_location.sol1
-rw-r--r--test/libsolidity/ASTJSON/source_location_legacy.json200
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive.json87
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive.sol1
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive_legacy.json110
-rw-r--r--test/libsolidity/ASTJSONTest.cpp201
-rw-r--r--test/libsolidity/ASTJSONTest.h58
-rw-r--r--test/libsolidity/ASTLegacyJSON.cpp324
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp1
-rw-r--r--test/libsolidity/syntaxTests/emit/emit_empty.sol (renamed from test/libsolidity/syntaxTests/emit_empty.sol)0
-rw-r--r--test/libsolidity/syntaxTests/emit/emit_non_event.sol (renamed from test/libsolidity/syntaxTests/emit_non_event.sol)0
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array.sol5
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array_2.sol4
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/events/event_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/events/event_struct_indexed.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/var_type_suggest.sol12
-rw-r--r--test/tools/CMakeLists.txt2
-rw-r--r--test/tools/isoltest.cpp38
69 files changed, 5111 insertions, 473 deletions
diff --git a/Changelog.md b/Changelog.md
index 89841cf0..856ea1ca 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -81,6 +81,7 @@ Bugfixes:
* References Resolver: Enforce ``storage`` as data location for mappings.
* References Resolver: Report error instead of assertion fail when FunctionType has an undeclared type as parameter.
* Type Checker: Consider fixed size arrays when checking for recursive structs.
+ * Type Checker: Report error when using structs in events without experimental ABIEncoderV2. This used to crash or log the wrong values.
* Type System: Allow arbitrary exponents for literals with a mantissa of zero.
### 0.4.24 (2018-05-16)
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index e868d111..af4d44a6 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -817,6 +817,7 @@ void TypeChecker::visitManually(
bool TypeChecker::visit(EventDefinition const& _eventDef)
{
+ solAssert(_eventDef.visibility() > Declaration::Visibility::Internal, "");
unsigned numIndexed = 0;
for (ASTPointer<VariableDeclaration> const& var: _eventDef.parameters())
{
@@ -826,6 +827,15 @@ bool TypeChecker::visit(EventDefinition const& _eventDef)
m_errorReporter.typeError(var->location(), "Type is required to live outside storage.");
if (!type(*var)->interfaceType(false))
m_errorReporter.typeError(var->location(), "Internal or recursive type is not allowed as event parameter type.");
+ if (
+ !_eventDef.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) &&
+ !typeSupportedByOldABIEncoder(*type(*var))
+ )
+ m_errorReporter.typeError(
+ var->location(),
+ "This type is only supported in the new experimental ABI encoder. "
+ "Use \"pragma experimental ABIEncoderV2;\" to enable the feature."
+ );
}
if (_eventDef.isAnonymous() && numIndexed > 4)
m_errorReporter.typeError(_eventDef.location(), "More than 4 indexed arguments for anonymous event.");
@@ -1034,7 +1044,10 @@ string createTupleDecl(vector<ASTPointer<VariableDeclaration>> const& _decls)
vector<string> components;
for (ASTPointer<VariableDeclaration> const& decl: _decls)
if (decl)
+ {
+ solAssert(decl->annotation().type, "");
components.emplace_back(decl->annotation().type->toString(false) + " " + decl->name());
+ }
else
components.emplace_back();
@@ -1052,6 +1065,9 @@ bool typeCanBeExpressed(vector<ASTPointer<VariableDeclaration>> const& decls)
if (!decl)
continue;
+ if (!decl->annotation().type)
+ return false;
+
if (auto functionType = dynamic_cast<FunctionType const*>(decl->annotation().type.get()))
if (
functionType->kind() != FunctionType::Kind::Internal &&
diff --git a/test/boostTest.cpp b/test/boostTest.cpp
index 6c68100c..cef3b06f 100644
--- a/test/boostTest.cpp
+++ b/test/boostTest.cpp
@@ -36,6 +36,7 @@
#pragma GCC diagnostic pop
#include <test/Options.h>
+#include <test/libsolidity/ASTJSONTest.h>
#include <test/libsolidity/SyntaxTest.h>
#include <boost/algorithm/string.hpp>
@@ -131,6 +132,12 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
"syntaxTests",
SyntaxTest::create
) > 0, "no syntax tests found");
+ solAssert(registerTests(
+ master,
+ dev::test::Options::get().testPath / "libsolidity",
+ "ASTJSON",
+ ASTJSONTest::create
+ ) > 0, "no JSON AST tests found");
if (dev::test::Options::get().disableIPC)
{
for (auto suite: {
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
deleted file mode 100644
index 482b05e6..00000000
--- a/test/libsolidity/ASTJSON.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- This file is part of solidity.
-
- solidity is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- solidity is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with solidity. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @author Christian <c@ethdev.com>
- * @date 2016
- * Tests for the json ast output.
- */
-
-#include <test/Options.h>
-
-#include <libsolidity/interface/Exceptions.h>
-#include <libsolidity/interface/CompilerStack.h>
-#include <libsolidity/ast/ASTJsonConverter.h>
-
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-
-using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(SolidityASTJSON)
-
-BOOST_AUTO_TEST_CASE(short_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
- BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_memory_ptr");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[]");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name_ref)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
- BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeIdentifier"], "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr");
- BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeString"], "uint256[][]");
-}
-
-BOOST_AUTO_TEST_CASE(long_type_name_binary_operation)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint a = 2 + 3; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["initialValue"]["commonType"];
- BOOST_CHECK_EQUAL(varDecl["typeIdentifier"], "t_rational_5_by_1");
- BOOST_CHECK_EQUAL(varDecl["typeString"], "int_const 5");
-}
-
-BOOST_AUTO_TEST_CASE(long_type_name_identifier)
-{
- CompilerStack c;
- c.addSource("a", "contract c { uint[] a; function f() public { uint[] storage b = a; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][1]["body"]["statements"][0]["initialValue"];
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_storage");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[] storage ref");
-}
-
-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.addSource("c",
- "contract C {"
- " /** Some comment on Evt.*/ event Evt();"
- " /** Some comment on mod.*/ modifier mod() { _; }"
- " /** Some comment on fn.*/ function fn() public {}"
- "}"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 0;
- sourceIndices["b"] = 1;
- sourceIndices["c"] = 2;
- //same tests for non-legacy mode
- Json::Value astJsonA = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value documentationA = astJsonA["nodes"][0]["documentation"];
- BOOST_CHECK_EQUAL(documentationA, "This contract is empty");
- Json::Value astJsonB = ASTJsonConverter(false, sourceIndices).toJson(c.ast("b"));
- Json::Value documentationB = astJsonB["nodes"][0]["documentation"];
- BOOST_CHECK_EQUAL(documentationB, "This contract is empty and has a line-breaking comment.");
- Json::Value astJsonC = ASTJsonConverter(false, sourceIndices).toJson(c.ast("c"));
- Json::Value documentationC0 = astJsonC["nodes"][0]["nodes"][0]["documentation"];
- Json::Value documentationC1 = astJsonC["nodes"][0]["nodes"][1]["documentation"];
- Json::Value 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.");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
-} // end namespaces
diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json
new file mode 100644
index 00000000..e3a3bea9
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name.json
@@ -0,0 +1,76 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 4,
+ "src" : "13:8:1",
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "13:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 2,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "13:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "scope" : 5,
+ "src" : "0:24:1"
+ }
+ ],
+ "src" : "0:25:1"
+}
diff --git a/test/libsolidity/ASTJSON/array_type_name.sol b/test/libsolidity/ASTJSON/array_type_name.sol
new file mode 100644
index 00000000..202ecf02
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name.sol
@@ -0,0 +1 @@
+contract C { uint[] i; }
diff --git a/test/libsolidity/ASTJSON/array_type_name_legacy.json b/test/libsolidity/ASTJSON/array_type_name_legacy.json
new file mode 100644
index 00000000..80feb344
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name_legacy.json
@@ -0,0 +1,89 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 4,
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "13:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "ArrayTypeName",
+ "src" : "13:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "13:8:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "0:24:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:25:1"
+}
diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json
new file mode 100644
index 00000000..56b748c1
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation.json
@@ -0,0 +1,182 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ },
+ "id" : 2,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : "This contract is empty",
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 2,
+ "src" : "28:13:1"
+ }
+ ],
+ "src" : "28:14:1"
+},
+{
+ "absolutePath" : "b",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ },
+ "id" : 4,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : "This contract is empty\nand has a line-breaking comment.",
+ "fullyImplemented" : true,
+ "id" : 3,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 4,
+ "src" : "62:13:2"
+ }
+ ],
+ "src" : "62:14:2"
+},
+{
+ "absolutePath" : "c",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 15
+ ]
+ },
+ "id" : 16,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 15,
+ "linearizedBaseContracts" :
+ [
+ 15
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "anonymous" : false,
+ "documentation" : "Some comment on Evt.",
+ "id" : 6,
+ "name" : "Evt",
+ "nodeType" : "EventDefinition",
+ "parameters" :
+ {
+ "id" : 5,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "51:2:3"
+ },
+ "src" : "42:12:3"
+ },
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "99:6:3",
+ "statements" :
+ [
+ {
+ "id" : 8,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "101:1:3"
+ }
+ ]
+ },
+ "documentation" : "Some comment on mod.",
+ "id" : 10,
+ "name" : "mod",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "96:2:3"
+ },
+ "src" : "84:21:3",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 13,
+ "nodeType" : "Block",
+ "src" : "155:2:3",
+ "statements" : []
+ },
+ "documentation" : "Some comment on fn.",
+ "id" : 14,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "fn",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "145:2:3"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 12,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "155:0:3"
+ },
+ "scope" : 15,
+ "src" : "134:23:3",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 16,
+ "src" : "0:159:3"
+ }
+ ],
+ "src" : "0:160:3"
+}
diff --git a/test/libsolidity/ASTJSON/documentation.sol b/test/libsolidity/ASTJSON/documentation.sol
new file mode 100644
index 00000000..e65af9b4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation.sol
@@ -0,0 +1,17 @@
+// ---- SOURCE: a
+
+/**This contract is empty*/ contract C {}
+
+// ---- SOURCE: b
+
+/**This contract is empty
+ and has a line-breaking comment.*/
+contract C {}
+
+// ---- SOURCE: c
+
+contract C {
+ /** Some comment on Evt.*/ event Evt();
+ /** Some comment on mod.*/ modifier mod() { _; }
+ /** Some comment on fn.*/ function fn() public {}
+}
diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json
new file mode 100644
index 00000000..44ae537b
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation_legacy.json
@@ -0,0 +1,178 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "c",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 15
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 15
+ ],
+ "name" : "C",
+ "scope" : 16
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "anonymous" : false,
+ "documentation" : "Some comment on Evt.",
+ "name" : "Evt"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 5,
+ "name" : "ParameterList",
+ "src" : "51:2:3"
+ }
+ ],
+ "id" : 6,
+ "name" : "EventDefinition",
+ "src" : "42:12:3"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : "Some comment on mod.",
+ "name" : "mod",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "96:2:3"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 8,
+ "name" : "PlaceholderStatement",
+ "src" : "101:1:3"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "99:6:3"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierDefinition",
+ "src" : "84:21:3"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : "Some comment on fn.",
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "fn",
+ "payable" : false,
+ "scope" : 15,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "145:2:3"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "ParameterList",
+ "src" : "155:0:3"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 13,
+ "name" : "Block",
+ "src" : "155:2:3"
+ }
+ ],
+ "id" : 14,
+ "name" : "FunctionDefinition",
+ "src" : "134:23:3"
+ }
+ ],
+ "id" : 15,
+ "name" : "ContractDefinition",
+ "src" : "0:159:3"
+ }
+ ],
+ "id" : 16,
+ "name" : "SourceUnit",
+ "src" : "0:160:3"
+}
diff --git a/test/libsolidity/ASTJSON/enum_value.json b/test/libsolidity/ASTJSON/enum_value.json
new file mode 100644
index 00000000..21afd9a7
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value.json
@@ -0,0 +1,57 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "canonicalName" : "C.E",
+ "id" : 3,
+ "members" :
+ [
+ {
+ "id" : 1,
+ "name" : "A",
+ "nodeType" : "EnumValue",
+ "src" : "22:1:1"
+ },
+ {
+ "id" : 2,
+ "name" : "B",
+ "nodeType" : "EnumValue",
+ "src" : "25:1:1"
+ }
+ ],
+ "name" : "E",
+ "nodeType" : "EnumDefinition",
+ "src" : "13:15:1"
+ }
+ ],
+ "scope" : 5,
+ "src" : "0:30:1"
+ }
+ ],
+ "src" : "0:31:1"
+}
diff --git a/test/libsolidity/ASTJSON/enum_value.sol b/test/libsolidity/ASTJSON/enum_value.sol
new file mode 100644
index 00000000..ef0875fb
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value.sol
@@ -0,0 +1 @@
+contract C { enum E { A, B } }
diff --git a/test/libsolidity/ASTJSON/enum_value_legacy.json b/test/libsolidity/ASTJSON/enum_value_legacy.json
new file mode 100644
index 00000000..d7782969
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value_legacy.json
@@ -0,0 +1,78 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "canonicalName" : "C.E",
+ "name" : "E"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "A"
+ },
+ "id" : 1,
+ "name" : "EnumValue",
+ "src" : "22:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "name" : "B"
+ },
+ "id" : 2,
+ "name" : "EnumValue",
+ "src" : "25:1:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "EnumDefinition",
+ "src" : "13:15:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "0:30:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:31:1"
+}
diff --git a/test/libsolidity/ASTJSON/event_definition.json b/test/libsolidity/ASTJSON/event_definition.json
new file mode 100644
index 00000000..029062c3
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition.json
@@ -0,0 +1,50 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ },
+ "id" : 4,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 3,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "anonymous" : false,
+ "documentation" : null,
+ "id" : 2,
+ "name" : "E",
+ "nodeType" : "EventDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "20:2:1"
+ },
+ "src" : "13:10:1"
+ }
+ ],
+ "scope" : 4,
+ "src" : "0:25:1"
+ }
+ ],
+ "src" : "0:26:1"
+}
diff --git a/test/libsolidity/ASTJSON/event_definition.sol b/test/libsolidity/ASTJSON/event_definition.sol
new file mode 100644
index 00000000..81b43c67
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition.sol
@@ -0,0 +1 @@
+contract C { event E(); }
diff --git a/test/libsolidity/ASTJSON/event_definition_legacy.json b/test/libsolidity/ASTJSON/event_definition_legacy.json
new file mode 100644
index 00000000..f5967bf4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition_legacy.json
@@ -0,0 +1,74 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "scope" : 4
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "anonymous" : false,
+ "documentation" : null,
+ "name" : "E"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "20:2:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "EventDefinition",
+ "src" : "13:10:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ContractDefinition",
+ "src" : "0:25:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "SourceUnit",
+ "src" : "0:26:1"
+}
diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json
new file mode 100644
index 00000000..f0389d17
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type.json
@@ -0,0 +1,230 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 17
+ ]
+ },
+ "id" : 18,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 17,
+ "linearizedBaseContracts" :
+ [
+ 17
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 15,
+ "nodeType" : "Block",
+ "src" : "120:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 16,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "24:44:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_payable$__$returns$_t_uint256_$",
+ "typeString" : "function () payable external returns (uint256)"
+ },
+ "typeName" :
+ {
+ "id" : 5,
+ "isDeclaredConst" : false,
+ "nodeType" : "FunctionTypeName",
+ "parameterTypes" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "32:2:1"
+ },
+ "payable" : true,
+ "returnParameterTypes" :
+ {
+ "id" : 4,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "61:4:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 2,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "61:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "60:6:1"
+ },
+ "src" : "24:44:1",
+ "stateMutability" : "payable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_payable$__$returns$_t_uint256_$",
+ "typeString" : "function () payable external returns (uint256)"
+ },
+ "visibility" : "external"
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:46:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 14,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 13,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "79:40:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_view$__$returns$_t_uint256_$",
+ "typeString" : "function () view external returns (uint256)"
+ },
+ "typeName" :
+ {
+ "id" : 12,
+ "isDeclaredConst" : true,
+ "nodeType" : "FunctionTypeName",
+ "parameterTypes" :
+ {
+ "id" : 8,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "87:2:1"
+ },
+ "payable" : false,
+ "returnParameterTypes" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 10,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "113:4:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 9,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "113:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "112:6:1"
+ },
+ "src" : "79:40:1",
+ "stateMutability" : "view",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_view$__$returns$_t_uint256_$",
+ "typeString" : "function () view external returns (uint256)"
+ },
+ "visibility" : "external"
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "78:41:1"
+ },
+ "scope" : 17,
+ "src" : "13:109:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 18,
+ "src" : "0:124:1"
+ }
+ ],
+ "src" : "0:125:1"
+}
diff --git a/test/libsolidity/ASTJSON/function_type.sol b/test/libsolidity/ASTJSON/function_type.sol
new file mode 100644
index 00000000..b63bcbf0
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type.sol
@@ -0,0 +1 @@
+contract C { function f(function() external payable returns (uint) x) returns (function() external view returns (uint)) {} }
diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json
new file mode 100644
index 00000000..4db5fb1c
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type_legacy.json
@@ -0,0 +1,271 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 17
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 17
+ ],
+ "name" : "C",
+ "scope" : 18
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 17,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "function () payable external returns (uint256)",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "payable" : true,
+ "stateMutability" : "payable",
+ "type" : "function () payable external returns (uint256)",
+ "visibility" : "external"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "32:2:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 2,
+ "name" : "ElementaryTypeName",
+ "src" : "61:4:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "61:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ParameterList",
+ "src" : "60:6:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "FunctionTypeName",
+ "src" : "24:44:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "VariableDeclaration",
+ "src" : "24:44:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "23:46:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "function () view external returns (uint256)",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : true,
+ "payable" : false,
+ "stateMutability" : "view",
+ "type" : "function () view external returns (uint256)",
+ "visibility" : "external"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 8,
+ "name" : "ParameterList",
+ "src" : "87:2:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 9,
+ "name" : "ElementaryTypeName",
+ "src" : "113:4:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "VariableDeclaration",
+ "src" : "113:4:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "112:6:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "FunctionTypeName",
+ "src" : "79:40:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "VariableDeclaration",
+ "src" : "79:40:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ParameterList",
+ "src" : "78:41:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 15,
+ "name" : "Block",
+ "src" : "120:2:1"
+ }
+ ],
+ "id" : 16,
+ "name" : "FunctionDefinition",
+ "src" : "13:109:1"
+ }
+ ],
+ "id" : 17,
+ "name" : "ContractDefinition",
+ "src" : "0:124:1"
+ }
+ ],
+ "id" : 18,
+ "name" : "SourceUnit",
+ "src" : "0:125:1"
+}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json
new file mode 100644
index 00000000..edef8677
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier.json
@@ -0,0 +1,80 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C1" :
+ [
+ 1
+ ],
+ "C2" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C1",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 5,
+ "src" : "0:14:1"
+ },
+ {
+ "baseContracts" :
+ [
+ {
+ "arguments" : null,
+ "baseName" :
+ {
+ "contractScope" : null,
+ "id" : 2,
+ "name" : "C1",
+ "nodeType" : "UserDefinedTypeName",
+ "referencedDeclaration" : 1,
+ "src" : "30:2:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_contract$_C1_$1",
+ "typeString" : "contract C1"
+ }
+ },
+ "id" : 3,
+ "nodeType" : "InheritanceSpecifier",
+ "src" : "30:2:1"
+ }
+ ],
+ "contractDependencies" :
+ [
+ 1
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4,
+ 1
+ ],
+ "name" : "C2",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 5,
+ "src" : "15:20:1"
+ }
+ ],
+ "src" : "0:36:1"
+}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.sol b/test/libsolidity/ASTJSON/inheritance_specifier.sol
new file mode 100644
index 00000000..02dbf0c5
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier.sol
@@ -0,0 +1 @@
+contract C1 {} contract C2 is C1 {}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json
new file mode 100644
index 00000000..0fcf2939
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json
@@ -0,0 +1,105 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C1" :
+ [
+ 1
+ ],
+ "C2" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C1",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 5
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:14:1"
+ },
+ {
+ "attributes" :
+ {
+ "contractDependencies" :
+ [
+ 1
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4,
+ 1
+ ],
+ "name" : "C2",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "arguments" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "contractScope" : null,
+ "name" : "C1",
+ "referencedDeclaration" : 1,
+ "type" : "contract C1"
+ },
+ "id" : 2,
+ "name" : "UserDefinedTypeName",
+ "src" : "30:2:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "InheritanceSpecifier",
+ "src" : "30:2:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "15:20:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:36:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json
new file mode 100644
index 00000000..6a956ca4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json
@@ -0,0 +1,177 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "33:19:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 4
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 4,
+ "name" : "a",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "35:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 3,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 8,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "commonType" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ },
+ "id" : 7,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "leftExpression" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "32",
+ "id" : 5,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "44:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_2_by_1",
+ "typeString" : "int_const 2"
+ },
+ "value" : "2"
+ },
+ "nodeType" : "BinaryOperation",
+ "operator" : "+",
+ "rightExpression" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "33",
+ "id" : 6,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "48:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_3_by_1",
+ "typeString" : "int_const 3"
+ },
+ "value" : "3"
+ },
+ "src" : "44:5:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:14:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:39:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:54:1"
+ }
+ ],
+ "src" : "0:55:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol
new file mode 100644
index 00000000..f07029d7
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint a = 2 + 3; } }
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json
new file mode 100644
index 00000000..cd4eefb1
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json
@@ -0,0 +1,209 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 4
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "a",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 3,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "VariableDeclaration",
+ "src" : "35:6:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "commonType" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ },
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "operator" : "+",
+ "type" : "int_const 5"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "32",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 2",
+ "value" : "2"
+ },
+ "id" : 5,
+ "name" : "Literal",
+ "src" : "44:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "33",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 3",
+ "value" : "3"
+ },
+ "id" : 6,
+ "name" : "Literal",
+ "src" : "48:1:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "BinaryOperation",
+ "src" : "44:5:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:14:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "33:19:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:39:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:54:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:55:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json
new file mode 100644
index 00000000..b1f8faa2
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json
@@ -0,0 +1,183 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "a",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 14,
+ "src" : "13:8:1",
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "13:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 2,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "13:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "43:25:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 9
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 9,
+ "name" : "b",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 12,
+ "src" : "45:16:1",
+ "stateVariable" : false,
+ "storageLocation" : "storage",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 7,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "45:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 8,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "45:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 11,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "id" : 10,
+ "name" : "a",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 3,
+ "src" : "64:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[] storage ref"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "45:20:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 4,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 5,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "43:0:1"
+ },
+ "scope" : 14,
+ "src" : "23:45:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:70:1"
+ }
+ ],
+ "src" : "0:71:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.sol b/test/libsolidity/ASTJSON/long_type_name_identifier.sol
new file mode 100644
index 00000000..f03f7a84
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier.sol
@@ -0,0 +1 @@
+contract c { uint[] a; function f() public { uint[] storage b = a; } }
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json
new file mode 100644
index 00000000..d7739f10
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json
@@ -0,0 +1,221 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "c",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "a",
+ "scope" : 14,
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "13:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "ArrayTypeName",
+ "src" : "13:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "13:8:1"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 4,
+ "name" : "ParameterList",
+ "src" : "33:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 5,
+ "name" : "ParameterList",
+ "src" : "43:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 9
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "b",
+ "scope" : 12,
+ "stateVariable" : false,
+ "storageLocation" : "storage",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 7,
+ "name" : "ElementaryTypeName",
+ "src" : "45:4:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ArrayTypeName",
+ "src" : "45:6:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "VariableDeclaration",
+ "src" : "45:16:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 3,
+ "type" : "uint256[] storage ref",
+ "value" : "a"
+ },
+ "id" : 10,
+ "name" : "Identifier",
+ "src" : "64:1:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "VariableDeclarationStatement",
+ "src" : "45:20:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "43:25:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "23:45:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:70:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:71:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json
new file mode 100644
index 00000000..da64b78d
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition.json
@@ -0,0 +1,176 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 5,
+ "nodeType" : "Block",
+ "src" : "32:6:1",
+ "statements" :
+ [
+ {
+ "id" : 4,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 6,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 3,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 2,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "24:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "24:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:8:1"
+ },
+ "src" : "13:25:1",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "64:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" :
+ [
+ {
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "hexValue" : "31",
+ "id" : 9,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "54:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_1_by_1",
+ "typeString" : "int_const 1"
+ },
+ "value" : "1"
+ }
+ ],
+ "id" : 10,
+ "modifierName" :
+ {
+ "argumentTypes" : null,
+ "id" : 8,
+ "name" : "M",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "52:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_modifier$_t_uint256_$",
+ "typeString" : "modifier (uint256)"
+ }
+ },
+ "nodeType" : "ModifierInvocation",
+ "src" : "52:4:1"
+ }
+ ],
+ "name" : "F",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "49:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "64:0:1"
+ },
+ "scope" : 14,
+ "src" : "39:27:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:68:1"
+ }
+ ],
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_definition.sol b/test/libsolidity/ASTJSON/modifier_definition.sol
new file mode 100644
index 00000000..96474e0f
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition.sol
@@ -0,0 +1 @@
+contract C { modifier M(uint i) { _; } function F() M(1) public {} }
diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json
new file mode 100644
index 00000000..f38d07be
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json
@@ -0,0 +1,213 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "24:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "VariableDeclaration",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ParameterList",
+ "src" : "23:8:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 4,
+ "name" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "Block",
+ "src" : "32:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ModifierDefinition",
+ "src" : "13:25:1"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "name" : "F",
+ "payable" : false,
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "49:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "64:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "modifier (uint256)",
+ "value" : "M"
+ },
+ "id" : 8,
+ "name" : "Identifier",
+ "src" : "52:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "31",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 1",
+ "value" : "1"
+ },
+ "id" : 9,
+ "name" : "Literal",
+ "src" : "54:1:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierInvocation",
+ "src" : "52:4:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "64:2:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "39:27:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:68:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json
new file mode 100644
index 00000000..da64b78d
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation.json
@@ -0,0 +1,176 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 5,
+ "nodeType" : "Block",
+ "src" : "32:6:1",
+ "statements" :
+ [
+ {
+ "id" : 4,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 6,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 3,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 2,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "24:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "24:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:8:1"
+ },
+ "src" : "13:25:1",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "64:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" :
+ [
+ {
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "hexValue" : "31",
+ "id" : 9,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "54:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_1_by_1",
+ "typeString" : "int_const 1"
+ },
+ "value" : "1"
+ }
+ ],
+ "id" : 10,
+ "modifierName" :
+ {
+ "argumentTypes" : null,
+ "id" : 8,
+ "name" : "M",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "52:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_modifier$_t_uint256_$",
+ "typeString" : "modifier (uint256)"
+ }
+ },
+ "nodeType" : "ModifierInvocation",
+ "src" : "52:4:1"
+ }
+ ],
+ "name" : "F",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "49:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "64:0:1"
+ },
+ "scope" : 14,
+ "src" : "39:27:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:68:1"
+ }
+ ],
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_invocation.sol b/test/libsolidity/ASTJSON/modifier_invocation.sol
new file mode 100644
index 00000000..96474e0f
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation.sol
@@ -0,0 +1 @@
+contract C { modifier M(uint i) { _; } function F() M(1) public {} }
diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json
new file mode 100644
index 00000000..f38d07be
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json
@@ -0,0 +1,213 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "24:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "VariableDeclaration",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ParameterList",
+ "src" : "23:8:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 4,
+ "name" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "Block",
+ "src" : "32:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ModifierDefinition",
+ "src" : "13:25:1"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "name" : "F",
+ "payable" : false,
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "49:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "64:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "modifier (uint256)",
+ "value" : "M"
+ },
+ "id" : 8,
+ "name" : "Identifier",
+ "src" : "52:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "31",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 1",
+ "value" : "1"
+ },
+ "id" : 9,
+ "name" : "Literal",
+ "src" : "54:1:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierInvocation",
+ "src" : "52:4:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "64:2:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "39:27:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:68:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json
new file mode 100644
index 00000000..ec4804f1
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8.json
@@ -0,0 +1,124 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 8
+ ]
+ },
+ "id" : 9,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 8,
+ "linearizedBaseContracts" :
+ [
+ 8
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 6,
+ "nodeType" : "Block",
+ "src" : "33:20:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 3
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "35:5:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_string_memory_ptr",
+ "typeString" : "string"
+ },
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 5,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "ff",
+ "id" : 4,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "string",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "43:7:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9",
+ "typeString" : "literal_string (contains invalid UTF-8 sequence at position 0)"
+ },
+ "value" : null
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 7,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 8,
+ "src" : "13:40:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 9,
+ "src" : "0:55:1"
+ }
+ ],
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/non_utf8.sol b/test/libsolidity/ASTJSON/non_utf8.sol
new file mode 100644
index 00000000..b83f3d70
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8.sol
@@ -0,0 +1 @@
+contract C { function f() public { var x = hex"ff"; } }
diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json
new file mode 100644
index 00000000..d83d2d97
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json
@@ -0,0 +1,157 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 8
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 8
+ ],
+ "name" : "C",
+ "scope" : 9
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 8,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 3
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "string",
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" : [],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "35:5:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "ff",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "string",
+ "type" : "literal_string (contains invalid UTF-8 sequence at position 0)",
+ "value" : null
+ },
+ "id" : 4,
+ "name" : "Literal",
+ "src" : "43:7:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "Block",
+ "src" : "33:20:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "FunctionDefinition",
+ "src" : "13:40:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ContractDefinition",
+ "src" : "0:55:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "SourceUnit",
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/placeholder_statement.json b/test/libsolidity/ASTJSON/placeholder_statement.json
new file mode 100644
index 00000000..496e1500
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement.json
@@ -0,0 +1,64 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ]
+ },
+ "id" : 6,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 5,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 3,
+ "nodeType" : "Block",
+ "src" : "24:6:1",
+ "statements" :
+ [
+ {
+ "id" : 2,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "26:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 4,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "24:0:1"
+ },
+ "src" : "13:17:1",
+ "visibility" : "internal"
+ }
+ ],
+ "scope" : 6,
+ "src" : "0:32:1"
+ }
+ ],
+ "src" : "0:33:1"
+}
diff --git a/test/libsolidity/ASTJSON/placeholder_statement.sol b/test/libsolidity/ASTJSON/placeholder_statement.sol
new file mode 100644
index 00000000..cb2c0990
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement.sol
@@ -0,0 +1 @@
+contract C { modifier M { _; } }
diff --git a/test/libsolidity/ASTJSON/placeholder_statement_legacy.json b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json
new file mode 100644
index 00000000..a5582976
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json
@@ -0,0 +1,87 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "scope" : 6
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "24:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 2,
+ "name" : "PlaceholderStatement",
+ "src" : "26:1:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "Block",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ModifierDefinition",
+ "src" : "13:17:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ContractDefinition",
+ "src" : "0:32:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "SourceUnit",
+ "src" : "0:33:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json
new file mode 100644
index 00000000..32df8cde
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name.json
@@ -0,0 +1,128 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 10
+ ]
+ },
+ "id" : 11,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 10,
+ "linearizedBaseContracts" :
+ [
+ 10
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 8,
+ "nodeType" : "Block",
+ "src" : "33:20:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 6
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 8,
+ "src" : "35:15:1",
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_memory_ptr",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 4,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 5,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 7,
+ "initialValue" : null,
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 9,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 10,
+ "src" : "13:40:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 11,
+ "src" : "0:55:1"
+ }
+ ],
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name.sol b/test/libsolidity/ASTJSON/short_type_name.sol
new file mode 100644
index 00000000..533874ae
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint[] memory x; } }
diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json
new file mode 100644
index 00000000..d14954c8
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json
@@ -0,0 +1,164 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 10
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 10
+ ],
+ "name" : "c",
+ "scope" : 11
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 10,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 6
+ ],
+ "initialValue" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 8,
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 4,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ArrayTypeName",
+ "src" : "35:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "VariableDeclaration",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "Block",
+ "src" : "33:20:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "FunctionDefinition",
+ "src" : "13:40:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ContractDefinition",
+ "src" : "0:55:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "SourceUnit",
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json
new file mode 100644
index 00000000..ebe940cf
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref.json
@@ -0,0 +1,140 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "33:25:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 7
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 7,
+ "name" : "rows",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "35:20:1",
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_array$_t_uint256_$dyn_memory_$dyn_memory_ptr",
+ "typeString" : "uint256[][]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "baseType" :
+ {
+ "id" : 4,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 5,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "id" : 6,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:8:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr",
+ "typeString" : "uint256[][]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 8,
+ "initialValue" : null,
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:20:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:45:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:60:1"
+ }
+ ],
+ "src" : "0:61:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.sol b/test/libsolidity/ASTJSON/short_type_name_ref.sol
new file mode 100644
index 00000000..a808b982
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint[][] memory rows; } }
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json
new file mode 100644
index 00000000..aaf9b8be
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json
@@ -0,0 +1,177 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 7
+ ],
+ "initialValue" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "rows",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "type" : "uint256[][]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[][]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 4,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ArrayTypeName",
+ "src" : "35:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ArrayTypeName",
+ "src" : "35:8:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "VariableDeclaration",
+ "src" : "35:20:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:20:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "33:25:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:45:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:60:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:61:1"
+}
diff --git a/test/libsolidity/ASTJSON/smoke.json b/test/libsolidity/ASTJSON/smoke.json
new file mode 100644
index 00000000..f5369bfc
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke.json
@@ -0,0 +1,33 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ },
+ "id" : 2,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 2,
+ "src" : "0:13:1"
+ }
+ ],
+ "src" : "0:14:1"
+}
diff --git a/test/libsolidity/ASTJSON/smoke.sol b/test/libsolidity/ASTJSON/smoke.sol
new file mode 100644
index 00000000..2dde0d20
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke.sol
@@ -0,0 +1 @@
+contract C {}
diff --git a/test/libsolidity/ASTJSON/smoke_legacy.json b/test/libsolidity/ASTJSON/smoke_legacy.json
new file mode 100644
index 00000000..e01a3c9b
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke_legacy.json
@@ -0,0 +1,48 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 2
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:13:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "SourceUnit",
+ "src" : "0:14:1"
+}
diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json
new file mode 100644
index 00000000..bd9290fd
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location.json
@@ -0,0 +1,162 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "26:19:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 3
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "28:5:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ },
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 5,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "32",
+ "id" : 4,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "36:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_2_by_1",
+ "typeString" : "int_const 2"
+ },
+ "value" : "2"
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "28:9:1"
+ },
+ {
+ "expression" :
+ {
+ "argumentTypes" : null,
+ "id" : 7,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "nodeType" : "UnaryOperation",
+ "operator" : "++",
+ "prefix" : false,
+ "src" : "39:3:1",
+ "subExpression" :
+ {
+ "argumentTypes" : null,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 3,
+ "src" : "39:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ }
+ },
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ }
+ },
+ "id" : 8,
+ "nodeType" : "ExpressionStatement",
+ "src" : "39:3:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "26:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:32:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:47:1"
+ }
+ ],
+ "src" : "0:48:1"
+}
diff --git a/test/libsolidity/ASTJSON/source_location.sol b/test/libsolidity/ASTJSON/source_location.sol
new file mode 100644
index 00000000..1fcec2e6
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location.sol
@@ -0,0 +1 @@
+contract C { function f() { var x = 2; x++; } }
diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json
new file mode 100644
index 00000000..d046e6ae
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location_legacy.json
@@ -0,0 +1,200 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "C",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "26:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 3
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint8",
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" : [],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "28:5:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "32",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 2",
+ "value" : "2"
+ },
+ "id" : 4,
+ "name" : "Literal",
+ "src" : "36:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "VariableDeclarationStatement",
+ "src" : "28:9:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "operator" : "++",
+ "prefix" : false,
+ "type" : "uint8"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 3,
+ "type" : "uint8",
+ "value" : "x"
+ },
+ "id" : 6,
+ "name" : "Identifier",
+ "src" : "39:1:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "UnaryOperation",
+ "src" : "39:3:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ExpressionStatement",
+ "src" : "39:3:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "26:19:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:32:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:47:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:48:1"
+}
diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json
new file mode 100644
index 00000000..33caabb4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive.json
@@ -0,0 +1,87 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ],
+ "L" :
+ [
+ 1
+ ]
+ },
+ "id" : 6,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "library",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "L",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 6,
+ "src" : "0:12:1"
+ },
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 5,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "id" : 4,
+ "libraryName" :
+ {
+ "contractScope" : null,
+ "id" : 2,
+ "name" : "L",
+ "nodeType" : "UserDefinedTypeName",
+ "referencedDeclaration" : 1,
+ "src" : "32:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_contract$_L_$1",
+ "typeString" : "library L"
+ }
+ },
+ "nodeType" : "UsingForDirective",
+ "src" : "26:17:1",
+ "typeName" :
+ {
+ "id" : 3,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "38:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ }
+ }
+ ],
+ "scope" : 6,
+ "src" : "13:32:1"
+ }
+ ],
+ "src" : "0:46:1"
+}
diff --git a/test/libsolidity/ASTJSON/using_for_directive.sol b/test/libsolidity/ASTJSON/using_for_directive.sol
new file mode 100644
index 00000000..a882ad88
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive.sol
@@ -0,0 +1 @@
+library L {} contract C { using L for uint; }
diff --git a/test/libsolidity/ASTJSON/using_for_directive_legacy.json b/test/libsolidity/ASTJSON/using_for_directive_legacy.json
new file mode 100644
index 00000000..0827ef90
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive_legacy.json
@@ -0,0 +1,110 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ],
+ "L" :
+ [
+ 1
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "library",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "L",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 6
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:12:1"
+ },
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "scope" : 6
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "contractScope" : null,
+ "name" : "L",
+ "referencedDeclaration" : 1,
+ "type" : "library L"
+ },
+ "id" : 2,
+ "name" : "UserDefinedTypeName",
+ "src" : "32:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 3,
+ "name" : "ElementaryTypeName",
+ "src" : "38:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "UsingForDirective",
+ "src" : "26:17:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ContractDefinition",
+ "src" : "13:32:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "SourceUnit",
+ "src" : "0:46:1"
+}
diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp
new file mode 100644
index 00000000..05839c1f
--- /dev/null
+++ b/test/libsolidity/ASTJSONTest.cpp
@@ -0,0 +1,201 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <test/libsolidity/ASTJSONTest.h>
+#include <test/Options.h>
+#include <libsolidity/ast/ASTJsonConverter.h>
+#include <libsolidity/interface/CompilerStack.h>
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/throw_exception.hpp>
+#include <cctype>
+#include <fstream>
+#include <memory>
+#include <stdexcept>
+
+using namespace dev;
+using namespace solidity;
+using namespace dev::solidity::test;
+using namespace dev::solidity::test::formatting;
+using namespace std;
+namespace fs = boost::filesystem;
+using namespace boost::unit_test;
+
+ASTJSONTest::ASTJSONTest(string const& _filename)
+{
+ if (!boost::algorithm::ends_with(_filename, ".sol"))
+ BOOST_THROW_EXCEPTION(runtime_error("Invalid test contract file name: \"" + _filename + "\"."));
+
+ m_astFilename = _filename.substr(0, _filename.size() - 4) + ".json";
+ m_legacyAstFilename = _filename.substr(0, _filename.size() - 4) + "_legacy.json";
+
+ ifstream file(_filename);
+ if (!file)
+ BOOST_THROW_EXCEPTION(runtime_error("Cannot open test contract: \"" + _filename + "\"."));
+ file.exceptions(ios::badbit);
+
+ string sourceName;
+ string source;
+ string line;
+ string const sourceDelimiter("// ---- SOURCE: ");
+ string const delimiter("// ----");
+ while (getline(file, line))
+ {
+ if (boost::algorithm::starts_with(line, sourceDelimiter))
+ {
+ if (!sourceName.empty())
+ m_sources.emplace_back(sourceName, source);
+
+ sourceName = line.substr(sourceDelimiter.size(), string::npos);
+ source = string();
+ }
+ else if (!line.empty() && !boost::algorithm::starts_with(line, delimiter))
+ source += line + "\n";
+ }
+
+ m_sources.emplace_back(sourceName.empty() ? "a" : sourceName, source);
+
+ file.close();
+ file.open(m_astFilename);
+ if (file)
+ {
+ string line;
+ while (getline(file, line))
+ m_expectation += line + "\n";
+ }
+
+ file.close();
+ file.open(m_legacyAstFilename);
+ if (file)
+ {
+ string line;
+ while (getline(file, line))
+ m_expectationLegacy += line + "\n";
+ }
+}
+
+bool ASTJSONTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
+{
+ CompilerStack c;
+
+ map<string, unsigned> sourceIndices;
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ c.addSource(m_sources[i].first, m_sources[i].second);
+ sourceIndices[m_sources[i].first] = i + 1;
+ }
+
+ c.setEVMVersion(dev::test::Options::get().evmVersion());
+ c.parseAndAnalyze();
+
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ ostringstream result;
+ ASTJsonConverter(false, sourceIndices).print(result, c.ast(m_sources[i].first));
+ m_result += result.str();
+ if (i != m_sources.size() - 1)
+ m_result += ",";
+ m_result += "\n";
+ }
+
+ bool resultsMatch = true;
+
+ if (m_expectation != m_result)
+ {
+ string nextIndentLevel = _linePrefix + " ";
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
+ {
+ istringstream stream(m_expectation);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
+ {
+ istringstream stream(m_result);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ resultsMatch = false;
+ }
+
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ ostringstream result;
+ ASTJsonConverter(true, sourceIndices).print(result, c.ast(m_sources[i].first));
+ m_resultLegacy = result.str();
+ if (i != m_sources.size() - 1)
+ m_resultLegacy += ",";
+ m_resultLegacy += "\n";
+ }
+
+ if (m_expectationLegacy != m_resultLegacy)
+ {
+ string nextIndentLevel = _linePrefix + " ";
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result (legacy):" << endl;
+ {
+ istringstream stream(m_expectationLegacy);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result (legacy):" << endl;
+ {
+ istringstream stream(m_resultLegacy);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ resultsMatch = false;
+ }
+
+ return resultsMatch;
+}
+
+void ASTJSONTest::printSource(ostream& _stream, string const& _linePrefix, bool const) const
+{
+ for (auto const& source: m_sources)
+ {
+ if (m_sources.size() > 1 || source.first != "a")
+ _stream << _linePrefix << "// ---- SOURCE: " << source.first << endl << endl;
+ stringstream stream(source.second);
+ string line;
+ while (getline(stream, line))
+ _stream << _linePrefix << line << endl;
+ _stream << endl;
+ }
+}
+
+void ASTJSONTest::printUpdatedExpectations(std::ostream&, std::string const&) const
+{
+ ofstream file(m_astFilename.c_str());
+ if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write AST expectation to \"" + m_astFilename + "\"."));
+ file.exceptions(ios::badbit);
+ file << m_result;
+ file.flush();
+ file.close();
+ file.open(m_legacyAstFilename.c_str());
+ if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write legacy AST expectation to \"" + m_legacyAstFilename + "\"."));
+ file << m_resultLegacy;
+ file.flush();
+ file.close();
+}
diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h
new file mode 100644
index 00000000..6f24bb60
--- /dev/null
+++ b/test/libsolidity/ASTJSONTest.h
@@ -0,0 +1,58 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <test/libsolidity/FormattedScope.h>
+#include <test/libsolidity/TestCase.h>
+
+#include <iosfwd>
+#include <string>
+#include <vector>
+#include <utility>
+
+namespace dev
+{
+namespace solidity
+{
+namespace test
+{
+
+class ASTJSONTest: public TestCase
+{
+public:
+ static std::unique_ptr<TestCase> create(std::string const& _filename)
+ { return std::unique_ptr<TestCase>(new ASTJSONTest(_filename)); }
+ ASTJSONTest(std::string const& _filename);
+
+ virtual bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
+
+ virtual void printSource(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) const override;
+ virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override;
+private:
+ std::vector<std::pair<std::string, std::string>> m_sources;
+ std::string m_expectation;
+ std::string m_expectationLegacy;
+ std::string m_astFilename;
+ std::string m_legacyAstFilename;
+ std::string m_result;
+ std::string m_resultLegacy;
+};
+
+}
+}
+}
diff --git a/test/libsolidity/ASTLegacyJSON.cpp b/test/libsolidity/ASTLegacyJSON.cpp
deleted file mode 100644
index 69cb1bb9..00000000
--- a/test/libsolidity/ASTLegacyJSON.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- This file is part of solidity.
-
- solidity is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- solidity is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with solidity. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @author Christian <c@ethdev.com>
- * @date 2016
- * Tests for the json ast output.
- */
-
-#include <test/Options.h>
-
-#include <libsolidity/interface/Exceptions.h>
-#include <libsolidity/interface/CompilerStack.h>
-#include <libsolidity/ast/ASTJsonConverter.h>
-
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-
-using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(SolidityASTLegacyJSON)
-
-BOOST_AUTO_TEST_CASE(smoke_test)
-{
- CompilerStack c;
- c.addSource("a", "contract C {}");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- BOOST_CHECK_EQUAL(astJson["name"], "SourceUnit");
-}
-
-BOOST_AUTO_TEST_CASE(source_location)
-{
- CompilerStack c;
- c.addSource("a", "contract C { function f() { var x = 2; x++; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
- BOOST_CHECK_EQUAL(astJson["children"][0]["children"][0]["src"], "13:32:1");
-
-}
-
-BOOST_AUTO_TEST_CASE(inheritance_specifier)
-{
- CompilerStack c;
- c.addSource("a", "contract C1 {} contract C2 is C1 {}");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["children"][0]["name"], "UserDefinedTypeName");
- 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.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
- 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_CASE(enum_value)
-{
- CompilerStack c;
- c.addSource("a", "contract C { enum E { A, B } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
- BOOST_CHECK_EQUAL(enumDefinition["children"][0]["src"], "22:1:1");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["name"], "EnumValue");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["attributes"]["name"], "B");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["src"], "25:1:1");
-}
-
-BOOST_AUTO_TEST_CASE(modifier_definition)
-{
- CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
- BOOST_CHECK_EQUAL(modifier["src"], "13:25:1");
-}
-
-BOOST_AUTO_TEST_CASE(modifier_invocation)
-{
- CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
- BOOST_CHECK_EQUAL(modifier["children"][0]["attributes"]["type"], "modifier (uint256)");
- BOOST_CHECK_EQUAL(modifier["children"][0]["attributes"]["value"], "M");
- BOOST_CHECK_EQUAL(modifier["children"][1]["attributes"]["value"], "1");
-}
-
-BOOST_AUTO_TEST_CASE(event_definition)
-{
- CompilerStack c;
- c.addSource("a", "contract C { event E(); }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
- BOOST_CHECK_EQUAL(event["src"], "13:10:1");
-}
-
-BOOST_AUTO_TEST_CASE(array_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract C { uint[] i; }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["attributes"];
- BOOST_CHECK_EQUAL(arrayDecl["storageLocation"], "default");
- BOOST_CHECK_EQUAL(arrayDecl["type"], "uint256[]");
- Json::Value array = astJson["children"][0]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(array["name"], "ArrayTypeName");
- BOOST_CHECK_EQUAL(array["src"], "13:6:1");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["type"], "uint256[]");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name_ref)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["type"], "uint256[][]");
-}
-
-BOOST_AUTO_TEST_CASE(placeholder_statement)
-{
- CompilerStack c;
- c.addSource("a", "contract C { modifier M { _; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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");
-}
-
-BOOST_AUTO_TEST_CASE(non_utf8)
-{
- CompilerStack c;
- c.addSource("a", "contract C { function f() public { var x = hex\"ff\"; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(varDecl["attributes"]["type"], "string");
- BOOST_CHECK_EQUAL(varDecl["attributes"]["typeName"], Json::nullValue);
- 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");
- BOOST_CHECK_EQUAL(literal["attributes"]["token"], "string");
- BOOST_CHECK_EQUAL(literal["attributes"]["value"], Json::nullValue);
- BOOST_CHECK(literal["attributes"]["type"].asString().find("invalid") != string::npos);
-}
-
-BOOST_AUTO_TEST_CASE(function_type)
-{
- CompilerStack c;
- c.addSource("a",
- "contract C { function f(function() external payable returns (uint) x) "
- "returns (function() external view returns (uint)) {} }"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- 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];
- BOOST_CHECK_EQUAL(argument["name"], "VariableDeclaration");
- BOOST_CHECK_EQUAL(argument["attributes"]["name"], "x");
- BOOST_CHECK_EQUAL(argument["attributes"]["type"], "function () payable external returns (uint256)");
- Json::Value funType = argument["children"][0];
- BOOST_CHECK_EQUAL(funType["attributes"]["constant"], false);
- BOOST_CHECK_EQUAL(funType["attributes"]["payable"], true);
- BOOST_CHECK_EQUAL(funType["attributes"]["visibility"], "external");
- Json::Value retval = fun["children"][1]["children"][0];
- BOOST_CHECK_EQUAL(retval["name"], "VariableDeclaration");
- BOOST_CHECK_EQUAL(retval["attributes"]["name"], "");
- BOOST_CHECK_EQUAL(retval["attributes"]["type"], "function () view external returns (uint256)");
- funType = retval["children"][0];
- BOOST_CHECK_EQUAL(funType["attributes"]["constant"], true);
- BOOST_CHECK_EQUAL(funType["attributes"]["payable"], false);
- 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.addSource("c",
- "contract C {"
- " /** Some comment on Evt.*/ event Evt();"
- " /** Some comment on mod.*/ modifier mod() { _; }"
- " /** Some comment on fn.*/ function fn() public {}"
- "}"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- 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.");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
-} // end namespaces
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index f2d6d66f..0b2e23e6 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -980,6 +980,7 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
BOOST_AUTO_TEST_CASE(event_structs)
{
char const* text = R"(
+ pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; T[] sub; bytes b; }
struct T { uint[2] x; }
diff --git a/test/libsolidity/syntaxTests/emit_empty.sol b/test/libsolidity/syntaxTests/emit/emit_empty.sol
index 819d88fe..819d88fe 100644
--- a/test/libsolidity/syntaxTests/emit_empty.sol
+++ b/test/libsolidity/syntaxTests/emit/emit_empty.sol
diff --git a/test/libsolidity/syntaxTests/emit_non_event.sol b/test/libsolidity/syntaxTests/emit/emit_non_event.sol
index d5045ddf..d5045ddf 100644
--- a/test/libsolidity/syntaxTests/emit_non_event.sol
+++ b/test/libsolidity/syntaxTests/emit/emit_non_event.sol
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array.sol b/test/libsolidity/syntaxTests/events/event_nested_array.sol
new file mode 100644
index 00000000..70af63b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array.sol
@@ -0,0 +1,5 @@
+contract c {
+ event E(uint[][]);
+}
+// ----
+// TypeError: (25-33): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_2.sol b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol
new file mode 100644
index 00000000..5825650e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol
@@ -0,0 +1,4 @@
+contract c {
+ event E(uint[2][]);
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol
new file mode 100644
index 00000000..fd59e962
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint x; uint[][] arr; }
+ event E(S);
+}
+// ----
+// TypeError: (61-62): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_struct.sol b/test/libsolidity/syntaxTests/events/event_struct.sol
new file mode 100644
index 00000000..c955dc5e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_struct.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint a ; }
+ event E(S);
+}
+// ----
+// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol
new file mode 100644
index 00000000..69ee5017
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint a ; }
+ event E(S indexed);
+}
+// ----
+// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol
index 176fab96..cc35fdd6 100644
--- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol
+++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol
@@ -12,6 +12,10 @@ contract C {
var myblockhash = block.blockhash;
var (a, b) = (2, "troi");
var (x,, z) = h();
+ var (c, d) = ("");
+ var (k, l) = (2);
+ var (m, n) = 1;
+ var (o, p) = "";
}
}
// ----
@@ -21,3 +25,11 @@ contract C {
// SyntaxError: (293-326): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
// SyntaxError: (336-360): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead.
// SyntaxError: (370-387): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead.
+// TypeError: (397-414): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (397-414): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (424-440): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (424-440): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (450-464): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (450-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (474-489): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (474-489): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt
index 257b4f24..d6df0ac8 100644
--- a/test/tools/CMakeLists.txt
+++ b/test/tools/CMakeLists.txt
@@ -3,5 +3,5 @@ target_link_libraries(solfuzzer PRIVATE libsolc evmasm ${Boost_PROGRAM_OPTIONS_L
add_executable(isoltest isoltest.cpp ../Options.cpp ../libsolidity/TestCase.cpp ../libsolidity/SyntaxTest.cpp
../libsolidity/AnalysisFramework.cpp ../libsolidity/SolidityExecutionFramework.cpp ../ExecutionFramework.cpp
- ../RPCSession.cpp)
+ ../RPCSession.cpp ../libsolidity/ASTJSONTest.cpp)
target_link_libraries(isoltest PRIVATE libsolc solidity evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp
index bd4b0db9..7d15b07a 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -18,6 +18,7 @@
#include <libdevcore/CommonIO.h>
#include <test/libsolidity/AnalysisFramework.h>
#include <test/libsolidity/SyntaxTest.h>
+#include <test/libsolidity/ASTJSONTest.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -336,22 +337,53 @@ Allowed options)",
}
}
+ TestStats global_stats { 0, 0 };
+
fs::path syntaxTestPath = testPath / "libsolidity" / "syntaxTests";
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
{
auto stats = TestTool::processPath(SyntaxTest::create, testPath / "libsolidity", "syntaxTests", formatted);
- cout << endl << "Summary: ";
+ cout << endl << "Syntax Test Summary: ";
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
stats.successCount << "/" << stats.runCount;
- cout << " tests successful." << endl;
+ cout << " tests successful." << endl << endl;
- return stats ? 0 : 1;
+ global_stats.runCount += stats.runCount;
+ global_stats.successCount += stats.successCount;
}
else
{
cerr << "Syntax tests not found. Use the --testpath argument." << endl;
return 1;
}
+
+ fs::path astJsonTestPath = testPath / "libsolidity" / "ASTJSON";
+
+ if (fs::exists(astJsonTestPath) && fs::is_directory(astJsonTestPath))
+ {
+ auto stats = TestTool::processPath(ASTJSONTest::create, testPath / "libsolidity", "ASTJSON", formatted);
+
+ cout << endl << "JSON AST Test Summary: ";
+ FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
+ stats.successCount << "/" << stats.runCount;
+ cout << " tests successful." << endl << endl;
+
+ global_stats.runCount += stats.runCount;
+ global_stats.successCount += stats.successCount;
+ }
+ else
+ {
+ cerr << "JSON AST tests not found." << endl;
+ return 1;
+ }
+
+ cout << endl << "Summary: ";
+ FormattedScope(cout, formatted, {BOLD, global_stats ? GREEN : RED}) <<
+ global_stats.successCount << "/" << global_stats.runCount;
+ cout << " tests successful." << endl;
+
+
+ return global_stats ? 0 : 1;
}