mirror of https://github.com/lukechilds/rollup.git
Rich Harris
9 years ago
9 changed files with 115 additions and 8 deletions
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'top-level `this` expression is rewritten as `undefined`' |
|||
}; |
@ -0,0 +1,21 @@ |
|||
define(function () { 'use strict'; |
|||
|
|||
const fooContext = {}; |
|||
|
|||
function foo () { |
|||
// inside a function, `this` should be untouched...
|
|||
assert.strictEqual( this, fooContext ); |
|||
} |
|||
|
|||
const bar = () => { |
|||
// ...unless it's an arrow function
|
|||
assert.strictEqual( undefined, undefined ); |
|||
} |
|||
|
|||
foo.call( fooContext ); |
|||
bar.call( {} ); |
|||
|
|||
// outside a function, `this` is undefined
|
|||
assert.strictEqual( undefined, undefined ); |
|||
|
|||
}); |
@ -0,0 +1,19 @@ |
|||
'use strict'; |
|||
|
|||
const fooContext = {}; |
|||
|
|||
function foo () { |
|||
// inside a function, `this` should be untouched...
|
|||
assert.strictEqual( this, fooContext ); |
|||
} |
|||
|
|||
const bar = () => { |
|||
// ...unless it's an arrow function
|
|||
assert.strictEqual( undefined, undefined ); |
|||
} |
|||
|
|||
foo.call( fooContext ); |
|||
bar.call( {} ); |
|||
|
|||
// outside a function, `this` is undefined
|
|||
assert.strictEqual( undefined, undefined ); |
@ -0,0 +1,17 @@ |
|||
const fooContext = {}; |
|||
|
|||
function foo () { |
|||
// inside a function, `this` should be untouched...
|
|||
assert.strictEqual( this, fooContext ); |
|||
} |
|||
|
|||
const bar = () => { |
|||
// ...unless it's an arrow function
|
|||
assert.strictEqual( undefined, undefined ); |
|||
} |
|||
|
|||
foo.call( fooContext ); |
|||
bar.call( {} ); |
|||
|
|||
// outside a function, `this` is undefined
|
|||
assert.strictEqual( undefined, undefined ); |
@ -0,0 +1,22 @@ |
|||
(function () { |
|||
'use strict'; |
|||
|
|||
const fooContext = {}; |
|||
|
|||
function foo () { |
|||
// inside a function, `this` should be untouched...
|
|||
assert.strictEqual( this, fooContext ); |
|||
} |
|||
|
|||
const bar = () => { |
|||
// ...unless it's an arrow function
|
|||
assert.strictEqual( undefined, undefined ); |
|||
} |
|||
|
|||
foo.call( fooContext ); |
|||
bar.call( {} ); |
|||
|
|||
// outside a function, `this` is undefined
|
|||
assert.strictEqual( undefined, undefined ); |
|||
|
|||
}()); |
@ -0,0 +1,25 @@ |
|||
(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' ? factory() : |
|||
typeof define === 'function' && define.amd ? define(factory) : |
|||
(factory()); |
|||
}(this, function () { 'use strict'; |
|||
|
|||
const fooContext = {}; |
|||
|
|||
function foo () { |
|||
// inside a function, `this` should be untouched...
|
|||
assert.strictEqual( this, fooContext ); |
|||
} |
|||
|
|||
const bar = () => { |
|||
// ...unless it's an arrow function
|
|||
assert.strictEqual( undefined, undefined ); |
|||
} |
|||
|
|||
foo.call( fooContext ); |
|||
bar.call( {} ); |
|||
|
|||
// outside a function, `this` is undefined
|
|||
assert.strictEqual( undefined, undefined ); |
|||
|
|||
})); |
@ -1,4 +1,4 @@ |
|||
const fooContext = {} |
|||
const fooContext = {}; |
|||
|
|||
function foo () { |
|||
// inside a function, `this` should be untouched...
|
@ -1,4 +0,0 @@ |
|||
module.exports = { |
|||
description: 'this at top level is undefined', |
|||
babel: true |
|||
}; |
Loading…
Reference in new issue