test multiple return values from a solidity method

This commit is contained in:
F. Eugene Aumson
2018-09-13 14:25:54 -04:00
parent 401ef2edef
commit 4ade674ada
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
pragma solidity ^0.4.24;
contract MultipleReturnValues {
function methodWithMultipleReturnValues() public pure returns(int, int) {
return (0, 0);
}
}

View File

@@ -153,6 +153,26 @@ describe('#SolidityDocGenerator', () => {
expect(methodDoc.comment).to.equal('methodWithSolhintDirective @dev');
});
});
it('should document a method that returns multiple values', async () => {
const doc = await generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, ['MultipleReturnValues']);
expect(doc.MultipleReturnValues).to.not.be.undefined();
expect(doc.MultipleReturnValues.methods).to.not.be.undefined();
let methodWithMultipleReturnValues: SolidityMethod | undefined;
for (const method of doc.MultipleReturnValues.methods) {
if (method.name === 'methodWithMultipleReturnValues') {
methodWithMultipleReturnValues = method;
}
}
if (_.isUndefined(methodWithMultipleReturnValues)) {
throw new Error('method should not be undefined');
}
const returnType = methodWithMultipleReturnValues.returnType;
expect(returnType.typeDocType).to.equal('tuple');
if (_.isUndefined(returnType.tupleElements)) {
throw new Error('returnType.tupleElements should not be undefined');
}
expect(returnType.tupleElements.length).to.equal(2);
});
});
function verifyTokenTransferProxyABIIsDocumented(doc: DocAgnosticFormat, contractName: string): void {