Browse Source

test for method call side effects

contingency-plan
Rich-Harris 10 years ago
parent
commit
cca5997ed5
  1. 2
      src/ast/analyse.js
  2. 3
      test/samples/method-call-side-effects/_config.js
  3. 5
      test/samples/method-call-side-effects/main.js
  4. 6
      test/samples/method-call-side-effects/object.js
  5. 8
      test/samples/method-call-side-effects/thing.js
  6. 4
      test/test.js

2
src/ast/analyse.js

@ -165,7 +165,7 @@ export default function analyse ( ast, magicString, module ) {
node.arguments.forEach( addNode );
}
// TODO UpdateExpression
// TODO UpdateExpressions, method calls?
}
walk( statement, {

3
test/samples/method-call-side-effects/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'assumes methods may mutate objects passed in, and self'
};

5
test/samples/method-call-side-effects/main.js

@ -0,0 +1,5 @@
import object from './object';
import thing from './thing';
assert.ok( object.mutated );
assert.ok( thing.methodWasCalled );

6
test/samples/method-call-side-effects/object.js

@ -0,0 +1,6 @@
import thing from './thing';
var object = {};
thing.mutate( object );
export default object;

8
test/samples/method-call-side-effects/thing.js

@ -0,0 +1,8 @@
export default {
mutate: function ( object ) {
object.mutated = true;
this.methodWasCalled = true;
},
methodWasCalled: false
};

4
test/test.js

@ -36,6 +36,10 @@ describe( 'rollup', function () {
console.log( result.code );
throw err;
}
if ( config.show ) {
console.log( result.code + '\n\n\n' );
}
});
});
});

Loading…
Cancel
Save