diff options
author | Christian Parpart <christian@ethereum.org> | 2018-11-28 23:19:22 +0800 |
---|---|---|
committer | Christian Parpart <christian@ethereum.org> | 2018-12-01 00:07:12 +0800 |
commit | c48a5264be4221873fe02cac57f6a41a32010fea (patch) | |
tree | 441c9c554fb9521f41f4a143dc138a33afb03589 /test/libsolidity | |
parent | 22eff22492b2d569fe56b59763ddc1cd1cf9ccf4 (diff) | |
download | dexon-solidity-c48a5264be4221873fe02cac57f6a41a32010fea.tar.gz dexon-solidity-c48a5264be4221873fe02cac57f6a41a32010fea.tar.zst dexon-solidity-c48a5264be4221873fe02cac57f6a41a32010fea.zip |
liblangutil: SourceLocation: adds (shared) pointer to underlying CharStream source, eliminating sourceName
Also, adapted affecting code to those changes.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/Assembly.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index 620f9661..004917d4 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -52,13 +52,13 @@ namespace test namespace { -eth::AssemblyItems compileContract(string const& _sourceCode) +eth::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode) { ErrorList errors; ErrorReporter errorReporter(errors); Parser parser(errorReporter); ASTPointer<SourceUnit> sourceUnit; - BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(CharStream(_sourceCode, "")))); + BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(_sourceCode))); BOOST_CHECK(!!sourceUnit); map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes; @@ -104,7 +104,7 @@ void printAssemblyLocations(AssemblyItems const& _items) ", " << _loc.end << ", make_shared<string>(\"" << - *_loc.sourceName << + _loc.source->name() << "\"))) +" << endl; }; @@ -151,29 +151,32 @@ BOOST_AUTO_TEST_SUITE(Assembly) BOOST_AUTO_TEST_CASE(location_test) { - char const* sourceCode = R"( + auto sourceCode = make_shared<CharStream>(R"( contract test { function f() public returns (uint256 a) { return 16; } } - )"; + )", ""); AssemblyItems items = compileContract(sourceCode); bool hasShifts = dev::test::Options::get().evmVersion().hasBitwiseShifting(); + + auto codegenCharStream = make_shared<CharStream>("", "--CODEGEN--"); + vector<SourceLocation> locations = - vector<SourceLocation>(hasShifts ? 21 : 22, SourceLocation(2, 82, make_shared<string>(""))) + - vector<SourceLocation>(2, SourceLocation(20, 79, make_shared<string>(""))) + - vector<SourceLocation>(1, SourceLocation(8, 17, make_shared<string>("--CODEGEN--"))) + - vector<SourceLocation>(3, SourceLocation(5, 7, make_shared<string>("--CODEGEN--"))) + - vector<SourceLocation>(1, SourceLocation(30, 31, make_shared<string>("--CODEGEN--"))) + - vector<SourceLocation>(1, SourceLocation(27, 28, make_shared<string>("--CODEGEN--"))) + - vector<SourceLocation>(1, SourceLocation(20, 32, make_shared<string>("--CODEGEN--"))) + - vector<SourceLocation>(1, SourceLocation(5, 7, make_shared<string>("--CODEGEN--"))) + - vector<SourceLocation>(24, SourceLocation(20, 79, make_shared<string>(""))) + - vector<SourceLocation>(1, SourceLocation(49, 58, make_shared<string>(""))) + - vector<SourceLocation>(1, SourceLocation(72, 74, make_shared<string>(""))) + - vector<SourceLocation>(2, SourceLocation(65, 74, make_shared<string>(""))) + - vector<SourceLocation>(2, SourceLocation(20, 79, make_shared<string>(""))); + vector<SourceLocation>(hasShifts ? 21 : 22, SourceLocation(2, 82, sourceCode)) + + vector<SourceLocation>(2, SourceLocation(20, 79, sourceCode)) + + vector<SourceLocation>(1, SourceLocation(8, 17, codegenCharStream)) + + vector<SourceLocation>(3, SourceLocation(5, 7, codegenCharStream)) + + vector<SourceLocation>(1, SourceLocation(30, 31, codegenCharStream)) + + vector<SourceLocation>(1, SourceLocation(27, 28, codegenCharStream)) + + vector<SourceLocation>(1, SourceLocation(20, 32, codegenCharStream)) + + vector<SourceLocation>(1, SourceLocation(5, 7, codegenCharStream)) + + vector<SourceLocation>(24, SourceLocation(20, 79, sourceCode)) + + vector<SourceLocation>(1, SourceLocation(49, 58, sourceCode)) + + vector<SourceLocation>(1, SourceLocation(72, 74, sourceCode)) + + vector<SourceLocation>(2, SourceLocation(65, 74, sourceCode)) + + vector<SourceLocation>(2, SourceLocation(20, 79, sourceCode)); checkAssemblyLocations(items, locations); } |