Browse Source

add tests for some.global = "changed"

gh-109
Rich-Harris 9 years ago
parent
commit
14887c60fc
  1. 3
      test/form/unused-side-effect/_config.js
  2. 7
      test/form/unused-side-effect/_expected/amd.js
  3. 5
      test/form/unused-side-effect/_expected/cjs.js
  4. 3
      test/form/unused-side-effect/_expected/es6.js
  5. 7
      test/form/unused-side-effect/_expected/iife.js
  6. 11
      test/form/unused-side-effect/_expected/umd.js
  7. 6
      test/form/unused-side-effect/foo.js
  8. 2
      test/form/unused-side-effect/main.js
  9. 14
      test/function/modify-assumed-global/_config.js
  10. 3
      test/function/modify-assumed-global/main.js
  11. 15
      test/function/modify-assumed-global/math.js

3
test/form/unused-side-effect/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'side-effects to non-globals are not blindly included'
};

7
test/form/unused-side-effect/_expected/amd.js

@ -0,0 +1,7 @@
define(function () { 'use strict';
var foo = 42;
assert.equal( foo, 42 );
});

5
test/form/unused-side-effect/_expected/cjs.js

@ -0,0 +1,5 @@
'use strict';
var foo = 42;
assert.equal( foo, 42 );

3
test/form/unused-side-effect/_expected/es6.js

@ -0,0 +1,3 @@
var foo = 42;
assert.equal( foo, 42 );

7
test/form/unused-side-effect/_expected/iife.js

@ -0,0 +1,7 @@
(function () { 'use strict';
var foo = 42;
assert.equal( foo, 42 );
})();

11
test/form/unused-side-effect/_expected/umd.js

@ -0,0 +1,11 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
factory();
}(this, function () { 'use strict';
var foo = 42;
assert.equal( foo, 42 );
}));

6
test/form/unused-side-effect/foo.js

@ -0,0 +1,6 @@
var uid = 0;
uid = 1;
uid += 1;
uid++;
export var foo = 42;

2
test/form/unused-side-effect/main.js

@ -0,0 +1,2 @@
import { foo } from './foo';
assert.equal( foo, 42 );

14
test/function/modify-assumed-global/_config.js

@ -0,0 +1,14 @@
var assert = require( 'assert' );
var Math = {};
module.exports = {
description: 'side-effects to assumed globals are included',
context: {
Math: Math
},
exports: function ( exports ) {
assert.equal( Math.square( 3 ), 9 );
assert.equal( Math.cube( 3 ), 27 );
}
};

3
test/function/modify-assumed-global/main.js

@ -0,0 +1,3 @@
import { square } from './math';
assert.equal( square( 2 ), 4 );

15
test/function/modify-assumed-global/math.js

@ -0,0 +1,15 @@
function square ( x ) {
return x * x;
}
function cube ( x ) {
return x * x * x;
}
Math.square = square;
if ( true ) {
Math.cube = cube;
}
export { square };
Loading…
Cancel
Save