aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-04-07 00:37:01 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-04-10 20:08:22 +0800
commitf03695731b9b36cd4014620b7b63556a69b4e952 (patch)
tree7e9ef254705fc96cf53d625ca0aad9f43cddc87d
parent2bc4ec31e2526abac57ac2864fa5c4bc4a7cd3a1 (diff)
downloaddexon-solidity-f03695731b9b36cd4014620b7b63556a69b4e952.tar
dexon-solidity-f03695731b9b36cd4014620b7b63556a69b4e952.tar.gz
dexon-solidity-f03695731b9b36cd4014620b7b63556a69b4e952.tar.bz2
dexon-solidity-f03695731b9b36cd4014620b7b63556a69b4e952.tar.lz
dexon-solidity-f03695731b9b36cd4014620b7b63556a69b4e952.tar.xz
dexon-solidity-f03695731b9b36cd4014620b7b63556a69b4e952.tar.zst
dexon-solidity-f03695731b9b36cd4014620b7b63556a69b4e952.zip
Add source locations to syntax test expectations.
-rw-r--r--Changelog.md1
-rw-r--r--test/libsolidity/FormattedScope.h2
-rw-r--r--test/libsolidity/SyntaxTest.cpp88
-rw-r--r--test/libsolidity/SyntaxTest.h7
-rw-r--r--test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol2
-rw-r--r--test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol6
-rw-r--r--test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol8
-rw-r--r--test/libsolidity/syntaxTests/double_stateVariable_declaration.sol2
-rw-r--r--test/libsolidity/syntaxTests/double_variable_declaration.sol2
-rw-r--r--test/libsolidity/syntaxTests/double_variable_declaration_050.sol6
-rw-r--r--test/libsolidity/syntaxTests/empty_struct.sol2
-rw-r--r--test/libsolidity/syntaxTests/empty_struct_050.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol4
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_function_declaration.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol4
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol4
-rw-r--r--test/libsolidity/syntaxTests/scoping/name_shadowing.sol3
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_activation.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_for3.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol2
-rw-r--r--test/libsolidity/syntaxTests/smoke_test.sol2
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol8
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol10
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol6
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol12
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol2
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol2
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol2
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol2
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol2
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol2
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol2
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_default.sol4
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_default050.sol4
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_internal.sol2
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_private.sol2
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_public.sol2
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_public050.sol2
-rw-r--r--test/tools/isoltest.cpp71
55 files changed, 216 insertions, 108 deletions
diff --git a/Changelog.md b/Changelog.md
index eb35652f..9a910a1a 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -11,6 +11,7 @@ Features:
* Optimizer: Optimize across ``mload`` if ``msize()`` is not used.
* Static Analyzer: Error on duplicated super constructor calls as experimental 0.5.0 feature.
* Syntax Checker: Issue warning for empty structs (or error as experimental 0.5.0 feature).
+ * Syntax Tests: Add source locations to syntax test expectations.
* General: Introduce new constructor syntax using the ``constructor`` keyword as experimental 0.5.0 feature.
* Inheritance: Error when using empty parentheses for base class constructors that require arguments as experimental 0.5.0 feature.
* Inheritance: Error when using no parentheses in modifier-style constructor calls as experimental 0.5.0 feature.
diff --git a/test/libsolidity/FormattedScope.h b/test/libsolidity/FormattedScope.h
index 78560848..923404f0 100644
--- a/test/libsolidity/FormattedScope.h
+++ b/test/libsolidity/FormattedScope.h
@@ -38,6 +38,8 @@ static constexpr char const* GREEN = "\033[1;32m";
static constexpr char const* YELLOW = "\033[1;33m";
static constexpr char const* CYAN = "\033[1;36m";
static constexpr char const* BOLD = "\033[1m";
+static constexpr char const* RED_BACKGROUND = "\033[48;5;160m";
+static constexpr char const* ORANGE_BACKGROUND = "\033[48;5;166m";
static constexpr char const* INVERSE = "\033[7m";
}
diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp
index 329543bf..1c2355d5 100644
--- a/test/libsolidity/SyntaxTest.cpp
+++ b/test/libsolidity/SyntaxTest.cpp
@@ -34,17 +34,38 @@ namespace fs = boost::filesystem;
using namespace boost::unit_test;
template<typename IteratorType>
-void skipWhitespace(IteratorType& it, IteratorType end)
+void skipWhitespace(IteratorType& _it, IteratorType _end)
{
- while (it != end && isspace(*it))
- ++it;
+ while (_it != _end && isspace(*_it))
+ ++_it;
}
template<typename IteratorType>
-void skipSlashes(IteratorType& it, IteratorType end)
+void skipSlashes(IteratorType& _it, IteratorType _end)
{
- while (it != end && *it == '/')
- ++it;
+ while (_it != _end && *_it == '/')
+ ++_it;
+}
+
+void expect(string::iterator& _it, string::iterator _end, string::value_type _c)
+{
+ if (_it == _end || *_it != _c)
+ throw runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\".");
+ ++_it;
+}
+
+int parseUnsignedInteger(string::iterator &_it, string::iterator _end)
+{
+ if (_it == _end || !isdigit(*_it))
+ throw runtime_error("Invalid test expectation. Source location expected.");
+ int result = 0;
+ while (_it != _end && isdigit(*_it))
+ {
+ result *= 10;
+ result += *_it - '0';
+ ++_it;
+ }
+ return result;
}
SyntaxTest::SyntaxTest(string const& _filename)
@@ -60,22 +81,39 @@ SyntaxTest::SyntaxTest(string const& _filename)
bool SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
{
+ string const versionPragma = "pragma solidity >=0.0;\n";
m_compiler.reset();
- m_compiler.addSource("", "pragma solidity >=0.0;\n" + m_source);
+ m_compiler.addSource("", versionPragma + m_source);
m_compiler.setEVMVersion(dev::test::Options::get().evmVersion());
if (m_compiler.parse())
m_compiler.analyze();
for (auto const& currentError: filterErrors(m_compiler.errors(), true))
- m_errorList.emplace_back(SyntaxTestError{currentError->typeName(), errorMessage(*currentError)});
+ {
+ int locationStart = -1, locationEnd = -1;
+ if (auto location = boost::get_error_info<errinfo_sourceLocation>(*currentError))
+ {
+ // ignore the version pragma inserted by the testing tool when calculating locations.
+ if (location->start >= static_cast<int>(versionPragma.size()))
+ locationStart = location->start - versionPragma.size();
+ if (location->end >= static_cast<int>(versionPragma.size()))
+ locationEnd = location->end - versionPragma.size();
+ }
+ m_errorList.emplace_back(SyntaxTestError{
+ currentError->typeName(),
+ errorMessage(*currentError),
+ locationStart,
+ locationEnd
+ });
+ }
if (m_expectations != m_errorList)
{
string nextIndentLevel = _linePrefix + " ";
FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
printErrorList(_stream, m_expectations, nextIndentLevel, _formatted);
- FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:\n";
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
printErrorList(_stream, m_errorList, nextIndentLevel, _formatted);
return false;
}
@@ -99,6 +137,16 @@ void SyntaxTest::printErrorList(
_stream << _linePrefix;
_stream << error.type << ": ";
}
+ if (error.locationStart >= 0 || error.locationEnd >= 0)
+ {
+ _stream << "(";
+ if (error.locationStart >= 0)
+ _stream << error.locationStart;
+ _stream << "-";
+ if (error.locationEnd >= 0)
+ _stream << error.locationEnd;
+ _stream << "): ";
+ }
_stream << error.message << endl;
}
}
@@ -147,8 +195,28 @@ vector<SyntaxTestError> SyntaxTest::parseExpectations(istream& _stream)
skipWhitespace(it, line.end());
+ int locationStart = -1;
+ int locationEnd = -1;
+
+ if (it != line.end() && *it == '(')
+ {
+ ++it;
+ locationStart = parseUnsignedInteger(it, line.end());
+ expect(it, line.end(), '-');
+ locationEnd = parseUnsignedInteger(it, line.end());
+ expect(it, line.end(), ')');
+ expect(it, line.end(), ':');
+ }
+
+ skipWhitespace(it, line.end());
+
string errorMessage(it, line.end());
- expectations.emplace_back(SyntaxTestError{move(errorType), move(errorMessage)});
+ expectations.emplace_back(SyntaxTestError{
+ move(errorType),
+ move(errorMessage),
+ locationStart,
+ locationEnd
+ });
}
return expectations;
}
diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h
index dddd86ef..6159e789 100644
--- a/test/libsolidity/SyntaxTest.h
+++ b/test/libsolidity/SyntaxTest.h
@@ -40,9 +40,14 @@ struct SyntaxTestError
{
std::string type;
std::string message;
+ int locationStart;
+ int locationEnd;
bool operator==(SyntaxTestError const& _rhs) const
{
- return type == _rhs.type && message == _rhs.message;
+ return type == _rhs.type &&
+ message == _rhs.message &&
+ locationStart == _rhs.locationStart &&
+ locationEnd == _rhs.locationEnd;
}
};
diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol
index 2b6aa088..cb553fbe 100644
--- a/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol
+++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol
@@ -2,4 +2,4 @@ contract C {
uint constant a = a;
}
// ----
-// TypeError: The value of the constant a has a cyclic dependency via a.
+// TypeError: (17-36): The value of the constant a has a cyclic dependency via a.
diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol
index 461979f8..00f9bb0f 100644
--- a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol
+++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol
@@ -5,6 +5,6 @@ contract C {
uint constant d = 2 + a;
}
// ----
-// TypeError: The value of the constant a has a cyclic dependency via c.
-// TypeError: The value of the constant c has a cyclic dependency via d.
-// TypeError: The value of the constant d has a cyclic dependency via a.
+// TypeError: (17-40): The value of the constant a has a cyclic dependency via c.
+// TypeError: (71-111): The value of the constant c has a cyclic dependency via d.
+// TypeError: (117-140): The value of the constant d has a cyclic dependency via a.
diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol
index f63be05e..969ed50d 100644
--- a/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol
+++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol
@@ -5,7 +5,7 @@ contract C {
uint constant c = b;
}
// ----
-// TypeError: The value of the constant x has a cyclic dependency via a.
-// TypeError: The value of the constant a has a cyclic dependency via b.
-// TypeError: The value of the constant b has a cyclic dependency via c.
-// TypeError: The value of the constant c has a cyclic dependency via b.
+// TypeError: (17-36): The value of the constant x has a cyclic dependency via a.
+// TypeError: (42-65): The value of the constant a has a cyclic dependency via b.
+// TypeError: (71-90): The value of the constant b has a cyclic dependency via c.
+// TypeError: (96-115): The value of the constant c has a cyclic dependency via b.
diff --git a/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol b/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol
index c5507b64..fda4a17a 100644
--- a/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol
+++ b/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol
@@ -3,4 +3,4 @@ contract test {
uint128 variable;
}
// ----
-// DeclarationError: Identifier already declared.
+// DeclarationError: (36-52): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/double_variable_declaration.sol b/test/libsolidity/syntaxTests/double_variable_declaration.sol
index 3349cfec..9ab87959 100644
--- a/test/libsolidity/syntaxTests/double_variable_declaration.sol
+++ b/test/libsolidity/syntaxTests/double_variable_declaration.sol
@@ -5,4 +5,4 @@ contract test {
}
}
// ----
-// DeclarationError: Identifier already declared.
+// DeclarationError: (71-80): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol
index 9c2d40d5..2f47e6dc 100644
--- a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol
+++ b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol
@@ -6,6 +6,6 @@ contract test {
}
}
// ----
-// Warning: This declaration shadows an existing declaration.
-// Warning: Unused local variable.
-// Warning: Unused local variable.
+// Warning: (101-110): This declaration shadows an existing declaration.
+// Warning: (76-85): Unused local variable.
+// Warning: (101-110): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/empty_struct.sol b/test/libsolidity/syntaxTests/empty_struct.sol
index dcced618..12655309 100644
--- a/test/libsolidity/syntaxTests/empty_struct.sol
+++ b/test/libsolidity/syntaxTests/empty_struct.sol
@@ -2,4 +2,4 @@ contract test {
struct A {}
}
// ----
-// Warning: Defining empty structs is deprecated.
+// Warning: (17-28): Defining empty structs is deprecated.
diff --git a/test/libsolidity/syntaxTests/empty_struct_050.sol b/test/libsolidity/syntaxTests/empty_struct_050.sol
index dbec93c4..886f1f83 100644
--- a/test/libsolidity/syntaxTests/empty_struct_050.sol
+++ b/test/libsolidity/syntaxTests/empty_struct_050.sol
@@ -3,4 +3,4 @@ contract test {
struct A {}
}
// ----
-// SyntaxError: Defining empty structs is disallowed.
+// SyntaxError: (47-58): Defining empty structs is disallowed.
diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol
index b3fbd04a..0b18b995 100644
--- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol
+++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol
@@ -4,4 +4,4 @@ contract Base {
contract Derived is Base(2) { }
contract Derived2 is Base(), Derived() { }
// ----
-// Warning: Wrong argument count for constructor call: 0 arguments given but expected 1.
+// Warning: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1.
diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol
index b3728634..db04ab8c 100644
--- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol
+++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol
@@ -6,4 +6,4 @@ contract Base {
contract Derived is Base(2) { }
contract Derived2 is Base(), Derived() { }
// ----
-// TypeError: Wrong argument count for constructor call: 0 arguments given but expected 1.
+// TypeError: (132-138): Wrong argument count for constructor call: 0 arguments given but expected 1.
diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol
index 5483d5d7..015b33e5 100644
--- a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol
+++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol
@@ -6,4 +6,4 @@ contract Derived is Base, Base1 {
constructor(uint i) Base(i) public {}
}
// ----
-// Warning: Base constructor arguments given twice.
+// Warning: (138-145): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol
index 0c159a22..6cf68d2a 100644
--- a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol
+++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol
@@ -1,4 +1,4 @@
contract A { constructor() public { } }
contract B is A { constructor() A public { } }
// ----
-// Warning: Modifier-style base constructor call without arguments.
+// Warning: (72-73): Modifier-style base constructor call without arguments.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol
index 8b1af245..24cff54d 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol
@@ -2,4 +2,4 @@ contract A { constructor(uint) public { } }
contract B is A(2) { constructor() public { } }
contract C is B { constructor() A(3) public { } }
// ----
-// Warning: Base constructor arguments given twice.
+// Warning: (125-129): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol
index 6616c9a9..8d5df5bf 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol
@@ -4,4 +4,4 @@ contract A { constructor(uint) public { } }
contract B is A(2) { constructor() public { } }
contract C is B { constructor() A(3) public { } }
// ----
-// DeclarationError: Base constructor arguments given twice.
+// DeclarationError: (156-160): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol
index 1fb504fe..9ceaea5e 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol
@@ -1,4 +1,4 @@
contract A { constructor(uint) public { } }
contract B is A(2) { constructor() A(3) public { } }
// ----
-// Warning: Base constructor arguments given twice.
+// Warning: (79-83): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol
index 96eb1bb1..f9325f99 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol
@@ -3,4 +3,4 @@ pragma experimental "v0.5.0";
contract A { constructor(uint) public { } }
contract B is A(2) { constructor() A(3) public { } }
// ----
-// DeclarationError: Base constructor arguments given twice.
+// DeclarationError: (110-114): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol
index db9ffc85..e5c2aa36 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol
@@ -3,5 +3,5 @@ contract A is C(2) {}
contract B is C(2) {}
contract D is A, B { constructor() C(3) public {} }
// ----
-// Warning: Base constructor arguments given twice.
-// Warning: Base constructor arguments given twice.
+// Warning: (122-126): Base constructor arguments given twice.
+// Warning: (122-126): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol
index fe280ad5..1abf2992 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol
@@ -3,4 +3,4 @@ contract A is C(2) {}
contract B is C(2) {}
contract D is A, B {}
// ----
-// Warning: Base constructor arguments given twice.
+// Warning: (87-108): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol
index ea85aae7..e15242db 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol
@@ -3,4 +3,4 @@ contract A is C { constructor() C(2) public {} }
contract B is C { constructor() C(2) public {} }
contract D is A, B { }
// ----
-// Warning: Base constructor arguments given twice.
+// Warning: (141-163): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol
index 45a0770f..c55c41f2 100644
--- a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol
+++ b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol
@@ -6,5 +6,5 @@ contract Derived2 is Base {
constructor() Base(2) public { }
}
// ----
-// TypeError: Wrong argument count for constructor call: 1 arguments given but expected 2.
-// TypeError: Wrong argument count for modifier invocation: 1 arguments given but expected 2.
+// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2.
+// TypeError: (130-137): Wrong argument count for modifier invocation: 1 arguments given but expected 2.
diff --git a/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol
index c03fd97d..fd3067e3 100644
--- a/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol
+++ b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol
@@ -2,4 +2,4 @@ contract test {
uint256 ;
}
// ----
-// ParserError: Expected identifier, got 'Semicolon'
+// ParserError: (28-28): Expected identifier, got 'Semicolon'
diff --git a/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol b/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol
index 2841fd38..dfd67aaa 100644
--- a/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol
+++ b/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol
@@ -3,4 +3,4 @@ contract test {
function fun() public { }
}
// ----
-// DeclarationError: Function with same name and arguments defined twice.
+// DeclarationError: (20-45): Function with same name and arguments defined twice.
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol
index ea61d0f3..d90ec2d7 100644
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol
+++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol
@@ -5,4 +5,4 @@ contract test {
}
}
// ----
-// DeclarationError: Identifier already declared.
+// DeclarationError: (77-83): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol
index 22195963..06bfe7be 100644
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol
+++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: Unused local variable.
-// Warning: Unused local variable.
+// Warning: (87-93): Unused local variable.
+// Warning: (107-113): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol
index 6af89c93..1a5ff2f9 100644
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol
+++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol
@@ -5,4 +5,4 @@ contract test {
}
}
// ----
-// DeclarationError: Identifier already declared.
+// DeclarationError: (75-81): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol
index 73cddfed..20ea0349 100644
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol
+++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: Unused local variable.
-// Warning: Unused local variable.
+// Warning: (87-93): Unused local variable.
+// Warning: (105-111): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/scoping/name_shadowing.sol b/test/libsolidity/syntaxTests/scoping/name_shadowing.sol
index d16877f9..67ada4a4 100644
--- a/test/libsolidity/syntaxTests/scoping/name_shadowing.sol
+++ b/test/libsolidity/syntaxTests/scoping/name_shadowing.sol
@@ -3,5 +3,4 @@ contract test {
function f() pure public { uint32 variable; variable = 2; }
}
// ----
-// Warning: This declaration shadows an existing declaration.
-
+// Warning: (69-84): This declaration shadows an existing declaration.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping.sol b/test/libsolidity/syntaxTests/scoping/scoping.sol
index f47a3e99..34b055d9 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping.sol
@@ -8,4 +8,4 @@ contract test {
}
}
// ----
-// DeclarationError: Undeclared identifier.
+// DeclarationError: (123-124): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol
index 0ed74a00..7334bc49 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol
@@ -6,4 +6,4 @@ contract test {
}
}
// ----
-// DeclarationError: Undeclared identifier. Did you mean "x"?
+// DeclarationError: (85-86): Undeclared identifier. Did you mean "x"?
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol
index 9bc7d569..1814cb47 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol
@@ -8,4 +8,4 @@ contract test {
}
}
// ----
-// DeclarationError: Undeclared identifier.
+// DeclarationError: (154-155): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol
index 07503983..3e80b385 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol
@@ -7,4 +7,4 @@ contract test {
}
}
// ----
-// DeclarationError: Undeclared identifier.
+// DeclarationError: (93-94): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol
index e942020e..ab3dcefb 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol
@@ -5,4 +5,4 @@ contract test {
}
}
// ----
-// DeclarationError: Undeclared identifier. Did you mean "a"?
+// DeclarationError: (94-95): Undeclared identifier. Did you mean "a"?
diff --git a/test/libsolidity/syntaxTests/smoke_test.sol b/test/libsolidity/syntaxTests/smoke_test.sol
index 2d48098a..6abaff18 100644
--- a/test/libsolidity/syntaxTests/smoke_test.sol
+++ b/test/libsolidity/syntaxTests/smoke_test.sol
@@ -3,4 +3,4 @@ contract test {
function fun(uint256 arg1) public { uint256 y; y = arg1; }
}
// ----
-// Warning: Function state mutability can be restricted to pure
+// Warning: (42-100): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
index 9f57c3a4..c98d7a57 100644
--- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
@@ -5,7 +5,7 @@ contract C {
}
}
// ----
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
+// TypeError: (74-83): This type cannot be encoded.
+// TypeError: (85-86): This type cannot be encoded.
+// TypeError: (88-98): This type cannot be encoded.
+// TypeError: (100-115): This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
index a7d13215..f1b5606e 100644
--- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
@@ -6,8 +6,8 @@ contract C {
}
}
// ----
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
+// TypeError: (80-106): This type cannot be encoded.
+// TypeError: (108-113): This type cannot be encoded.
+// TypeError: (160-164): This type cannot be encoded.
+// TypeError: (166-168): This type cannot be encoded.
+// TypeError: (170-176): This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol
index 378155e9..cc354819 100644
--- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol
@@ -9,6 +9,6 @@ contract C {
}
}
// ----
-// Warning: Defining empty structs is deprecated.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
+// Warning: (51-63): Defining empty structs is deprecated.
+// TypeError: (131-132): This type cannot be encoded.
+// TypeError: (134-135): This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
index 6e073fd8..d10c1718 100644
--- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
@@ -9,9 +9,9 @@ contract C {
}
}
// ----
-// Warning: Defining empty structs is deprecated.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
-// TypeError: This type cannot be encoded.
+// Warning: (51-63): Defining empty structs is deprecated.
+// TypeError: (168-169): This type cannot be encoded.
+// TypeError: (171-172): This type cannot be encoded.
+// TypeError: (179-180): This type cannot be encoded.
+// TypeError: (182-186): This type cannot be encoded.
+// TypeError: (188-194): This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol
index 9a1c22f1..895bb6c5 100644
--- a/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol
+++ b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol
@@ -12,4 +12,4 @@ contract C {
function f(T) public pure { }
}
// ----
-// Warning: Experimental features are turned on. Do not use experimental features on live deployments.
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
diff --git a/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol
index d4ad088d..96362ef0 100644
--- a/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol
+++ b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol
@@ -12,4 +12,4 @@ contract TestContract
function addTestStruct(TestStruct) public pure {}
}
// ----
-// Warning: Experimental features are turned on. Do not use experimental features on live deployments.
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol
index c02a8aa4..4966a731 100644
--- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol
+++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
-// TypeError: Internal or recursive type is not allowed for public or external functions.
+// TypeError: (91-92): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol
index e9488cf4..68113924 100644
--- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol
+++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
-// TypeError: Internal or recursive type is not allowed for public or external functions.
+// TypeError: (94-95): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol
index 6728baec..47690d9b 100644
--- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol
+++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
-// TypeError: Internal or recursive type is not allowed for public or external functions.
+// TypeError: (119-122): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol
index cac2e23f..bcffe383 100644
--- a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol
+++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol
@@ -5,4 +5,4 @@ contract Test {
}
}
// ----
-// TypeError: Recursive struct definition.
+// TypeError: (20-93): Recursive struct definition.
diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol
index 11fc6307..64dab8d0 100644
--- a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol
+++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol
@@ -9,4 +9,4 @@ contract Test {
}
}
// ----
-// TypeError: Recursive struct definition.
+// TypeError: (20-118): Recursive struct definition.
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol
index 7b9044dd..72ce3b40 100644
--- a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol
+++ b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol
@@ -2,5 +2,5 @@ interface I {
function f();
}
// ----
-// Warning: Functions in interfaces should be declared external.
-// Warning: No visibility specified. Defaulting to "public". In interfaces it defaults to external.
+// Warning: (15-28): Functions in interfaces should be declared external.
+// Warning: (15-28): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol
index 127d4e92..513df26b 100644
--- a/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol
+++ b/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol
@@ -3,5 +3,5 @@ interface I {
function f();
}
// ----
-// SyntaxError: No visibility specified.
-// TypeError: Functions in interfaces must be declared external.
+// SyntaxError: (45-58): No visibility specified.
+// TypeError: (45-58): Functions in interfaces must be declared external.
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol
index a1cf5246..ac62e69b 100644
--- a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol
+++ b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol
@@ -2,4 +2,4 @@ interface I {
function f() internal;
}
// ----
-// TypeError: Functions in interfaces cannot be internal or private.
+// TypeError: (15-37): Functions in interfaces cannot be internal or private.
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol
index 887ebd4b..881e647e 100644
--- a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol
+++ b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol
@@ -2,4 +2,4 @@ interface I {
function f() private;
}
// ----
-// TypeError: Functions in interfaces cannot be internal or private.
+// TypeError: (15-36): Functions in interfaces cannot be internal or private.
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol
index 146d4f5b..891d9fdf 100644
--- a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol
+++ b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol
@@ -2,4 +2,4 @@ interface I {
function f() public;
}
// ----
-// Warning: Functions in interfaces should be declared external. \ No newline at end of file
+// Warning: (15-35): Functions in interfaces should be declared external.
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol
index f957f0b4..e0c04095 100644
--- a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol
+++ b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol
@@ -3,4 +3,4 @@ interface I {
function f() public;
}
// ----
-// TypeError: Functions in interfaces must be declared external. \ No newline at end of file
+// TypeError: (45-65): Functions in interfaces must be declared external.
diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp
index 07df8f60..7a147bd0 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -55,7 +55,6 @@ public:
{
Success,
Failure,
- InputOutputError,
Exception
};
@@ -90,11 +89,53 @@ string SyntaxTestTool::editor;
void SyntaxTestTool::printContract() const
{
- stringstream stream(m_test->source());
- string line;
- while (getline(stream, line))
- cout << " " << line << endl;
- cout << endl;
+ if (m_formatted)
+ {
+ string const& source = m_test->source();
+ if (source.empty())
+ return;
+
+ std::vector<char const*> sourceFormatting(source.length(), formatting::RESET);
+ for (auto const& error: m_test->errorList())
+ if (error.locationStart >= 0 && error.locationEnd >= 0)
+ {
+ assert(static_cast<size_t>(error.locationStart) < source.length());
+ assert(static_cast<size_t>(error.locationEnd) < source.length());
+ bool isWarning = error.type == "Warning";
+ for (int i = error.locationStart; i < error.locationEnd; i++)
+ if (isWarning)
+ {
+ if (sourceFormatting[i] == formatting::RESET)
+ sourceFormatting[i] = formatting::ORANGE_BACKGROUND;
+ }
+ else
+ sourceFormatting[i] = formatting::RED_BACKGROUND;
+ }
+
+ cout << " " << sourceFormatting.front() << source.front();
+ for (size_t i = 1; i < source.length(); i++)
+ {
+ if (sourceFormatting[i] != sourceFormatting[i - 1])
+ cout << sourceFormatting[i];
+ if (source[i] != '\n')
+ cout << source[i];
+ else
+ {
+ cout << formatting::RESET << endl;
+ if (i + 1 < source.length())
+ cout << " " << sourceFormatting[i];
+ }
+ }
+ cout << formatting::RESET << endl;
+ }
+ else
+ {
+ stringstream stream(m_test->source());
+ string line;
+ while (getline(stream, line))
+ cout << " " << line << endl;
+ cout << endl;
+ }
}
SyntaxTestTool::Result SyntaxTestTool::process()
@@ -107,15 +148,6 @@ SyntaxTestTool::Result SyntaxTestTool::process()
try
{
m_test = unique_ptr<SyntaxTest>(new SyntaxTest(m_path.string()));
- }
- catch (std::exception const& _e)
- {
- FormattedScope(cout, m_formatted, {BOLD, RED}) << "cannot read test: " << _e.what() << endl;
- return Result::InputOutputError;
- }
-
- try
- {
success = m_test->run(outputMessages, " ", m_formatted);
}
catch(CompilerError const& _e)
@@ -142,6 +174,11 @@ SyntaxTestTool::Result SyntaxTestTool::process()
"UnimplementedFeatureError: " << SyntaxTest::errorMessage(_e) << endl;
return Result::Exception;
}
+ catch (std::exception const& _e)
+ {
+ FormattedScope(cout, m_formatted, {BOLD, RED}) << "Exception: " << _e.what() << endl;
+ return Result::Exception;
+ }
catch(...)
{
FormattedScope(cout, m_formatted, {BOLD, RED}) <<
@@ -262,10 +299,6 @@ SyntaxTestStats SyntaxTestTool::processPath(
paths.pop();
++successCount;
break;
- default:
- // non-recoverable error; continue with next test case
- paths.pop();
- break;
}
}
}