2016-11-02 12:02:48 +01:00
|
|
|
'use strict'
|
|
|
|
|
var tape = require('tape')
|
2017-03-29 23:46:08 +07:00
|
|
|
var SourceMappingDecoder = require('../src/util/sourceMappingDecoder')
|
2016-11-02 12:02:48 +01:00
|
|
|
var compiler = require('solc')
|
|
|
|
|
|
|
|
|
|
tape('SourceMappingDecoder', function (t) {
|
|
|
|
|
t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) {
|
|
|
|
|
var output = compiler.compile(contracts, 0)
|
|
|
|
|
var sourceMappingDecoder = new SourceMappingDecoder()
|
2017-02-06 15:34:08 +01:00
|
|
|
var node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 2, output.contracts[':test'].srcmapRuntime, output.sources[''])
|
2016-11-02 12:02:48 +01:00
|
|
|
st.equal(node, null)
|
2017-07-19 14:57:46 +02:00
|
|
|
node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 80, output.contracts[':test'].srcmapRuntime, output.sources[''])
|
2016-11-02 12:02:48 +01:00
|
|
|
st.notEqual(node, null)
|
|
|
|
|
if (node) {
|
|
|
|
|
st.equal(node.attributes.name, 'f1')
|
|
|
|
|
}
|
|
|
|
|
st.end()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
var contracts = `contract test {
|
|
|
|
|
function f1() returns (uint) {
|
|
|
|
|
uint t = 4;
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function f2() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|