Browse Source

Add failing testcase for #68

contingency-plan
Arpad Borsos 10 years ago
parent
commit
cd109af17e
  1. 15
      test/function/named-external-method-in-prototype/_config.js
  2. 5
      test/function/named-external-method-in-prototype/bar.js
  3. 16
      test/function/named-external-method-in-prototype/foo.js
  4. 5
      test/function/named-external-method-in-prototype/main.js

15
test/function/named-external-method-in-prototype/_config.js

@ -0,0 +1,15 @@
module.exports = {
description: 'method of external named import used inside prototype method',
context: {
// override require here, making "foo" appear as a global module
require: function ( name ) {
if ( name === 'bar' ) {
return require( './bar' );
}
return require( name );
}
},
options: {
external: [ 'bar' ]
},
};

5
test/function/named-external-method-in-prototype/bar.js

@ -0,0 +1,5 @@
exports.bar = {
foobar: function () {
return 42;
}
};

16
test/function/named-external-method-in-prototype/foo.js

@ -0,0 +1,16 @@
import { bar } from 'bar';
export default function Foo() {
// XXX: one does not even have to call the method, simply having it defined
// on the prototype triggers the failure
//return this.bar();
return bar.foobar();
}
// XXX: this prototype definition throws it of, comment it out and it at least
// fails at runtime because it generates wrong code
Foo.prototype.bar = function () {
// XXX: it also has to be a nested function, simply calling `bar()` here
// works, or at least it fails ar runtime like the case above
return bar.foobar();
};

5
test/function/named-external-method-in-prototype/main.js

@ -0,0 +1,5 @@
// XXX: it has to be an imported module, otherwise it compiles and fails at
// runtime
import Foo from './foo.js';
assert.equal( new Foo(), 42 );
Loading…
Cancel
Save