Merge pull request #50 from sc-forks/tuple-return-bug

Fix tuple parsing / update tests
pull/51/head
c-g-e-w-e-k-e- 8 years ago committed by GitHub
commit 8b865d98fd
  1. 5
      lib/parse.js
  2. 8
      test/sources/statements/tuple.sol
  3. 8
      test/statements.js

@ -158,8 +158,9 @@ parse.VariableDeclaration = function parseVariableDeclaration(contract, expressi
}; };
parse.VariableDeclarationTuple = function parseVariableDeclarationTuple(contract, expression) { parse.VariableDeclarationTuple = function parseVariableDeclarationTuple(contract, expression) {
parse[expression.init.type] && instrumenter.instrumentStatement(contract, expression);
parse[expression.init.type](contract, expression.init); parse[expression.declarations[0].id.type] &&
parse[expression.declarations[0].id.type](contract, expression.declarations[0].id);
}; };
parse.WhileStatement = function parseWhileStatement(contract, expression) { parse.WhileStatement = function parseWhileStatement(contract, expression) {

@ -1,7 +1,13 @@
pragma solidity ^0.4.3; pragma solidity ^0.4.3;
contract Test { contract Test {
function returnTuple() returns (uint x, uint y) {
return (10, 20);
}
function a() { function a() {
var(x,y) = (10,20); var (a, b) = (10, 20);
var (x, y) = returnTuple();
} }
} }

@ -101,12 +101,14 @@ describe('generic statements', () => {
vm.execute(info.contract, 'a', []).then(events => { vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix); const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, { assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 10: 1, 11: 1
}); });
assert.deepEqual(mapping[filePath].b, {}); assert.deepEqual(mapping[filePath].b, {});
assert.deepEqual(mapping[filePath].s, {}); assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1
});
assert.deepEqual(mapping[filePath].f, { assert.deepEqual(mapping[filePath].f, {
1: 1, 1: 1, 2: 1
}); });
done(); done();
}).catch(done); }).catch(done);

Loading…
Cancel
Save