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.

29 lines
971 B

10 years ago
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 match = /Object\.create\( ([^\.]+)\.prototype/.exec( code );
var deconflictedName = match[1];
if ( deconflictedName !== 'Foo' ) throw new Error( 'Need to update this test!' );
10 years ago
10 years ago
var smc = new SourceMapConsumer( map );
10 years ago
var index = code.indexOf( deconflictedName );
10 years ago
var generatedLoc = getLocation( code, index );
var originalLoc = smc.originalPositionFor( generatedLoc );
assert.equal( originalLoc.name, null );
10 years ago
10 years ago
index = code.indexOf( deconflictedName, index + 1 );
10 years ago
generatedLoc = getLocation( code, index );
originalLoc = smc.originalPositionFor( generatedLoc );
assert.equal( originalLoc.name, 'Foo' );
10 years ago
}
};