You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
901 B

var assert = require( 'assert' );
var getLocation = require( '../../utils/getLocation' );
var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer;
module.exports = {
description: 'names are recovered (https://github.com/rollup/rollup/issues/101)',
options: {
moduleName: 'myModule'
},
test: function ( code, map ) {
var smc = new SourceMapConsumer( map );
var pattern = /Object\.create\( ([\w\$\d]+)\.prototype \)/;
var match = pattern.exec( code );
var generatedLoc = getLocation( code, match.index + 'Object.create ( '.length );
var original = smc.originalPositionFor( generatedLoc );
assert.equal( original.name, 'Bar' );
pattern = /function Foo([\w\$\d]+)/;
match = pattern.exec( code );
generatedLoc = getLocation( code, match.index + 'function '.length );
original = smc.originalPositionFor( generatedLoc );
assert.equal( original.name, 'Foo' );
}
};