-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
90 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'treat for-in variable as unknown' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
for (const name in {present: true}) { | ||
if (name !== 'present') { | ||
throw new Error('Always false for-in check was inlined'); | ||
} | ||
assert.equal(name, 'present'); | ||
} | ||
|
||
for (const name of ['present']) { | ||
if (name !== 'present') { | ||
throw new Error('Always false for-of check was inlined'); | ||
} | ||
assert.equal(name, 'present'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'members of namespaces are reassigned when the namespace is passed to a function' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const flags = {}; | ||
|
||
function test() { | ||
if (!flags.x) { | ||
throw new Error('Flag "x" not set'); | ||
} | ||
assert.ok(flags.x); | ||
} | ||
|
||
export { flags, test }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as foo from './foo.js'; | ||
|
||
function reassignFlagX(obj) { | ||
obj.flags.x = true; | ||
} | ||
|
||
reassignFlagX(foo); | ||
|
||
foo.test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,38 @@ | ||
const path = require('path'); | ||
const rollup = require('../..'); | ||
const weak = require('weak'); | ||
|
||
function test() { | ||
const weak = require('weak'); | ||
var shouldCollect = false; | ||
var isCollected = false; | ||
|
||
var shouldCollect = false; | ||
var isCollected = false; | ||
|
||
function onCollect() { | ||
isCollected = true; | ||
} | ||
|
||
var cache; | ||
function run() { | ||
return rollup | ||
.rollup({ | ||
input: path.resolve(__dirname, 'main.js'), | ||
cache | ||
}) | ||
.then(bundle => { | ||
weak(bundle, onCollect); | ||
cache = bundle; | ||
global.gc(); | ||
if (shouldCollect && !isCollected) { | ||
throw new Error('Memory leak detected'); | ||
} | ||
shouldCollect = true; | ||
}); | ||
} | ||
function onCollect() { | ||
isCollected = true; | ||
} | ||
|
||
run() | ||
.then(run) | ||
.then(() => { | ||
console.log('Success'); | ||
var cache; | ||
function run() { | ||
return rollup | ||
.rollup({ | ||
input: path.resolve(__dirname, 'main.js'), | ||
cache | ||
}) | ||
.catch(err => { | ||
console.error(err.message); | ||
process.exit(1); | ||
.then(bundle => { | ||
weak(bundle, onCollect); | ||
cache = bundle; | ||
global.gc(); | ||
if (shouldCollect && !isCollected) { | ||
throw new Error('Memory leak detected'); | ||
} | ||
shouldCollect = true; | ||
}); | ||
} | ||
|
||
try { | ||
require.resolve('weak'); | ||
test(); | ||
} catch (err) { | ||
console.error(err); | ||
console.log('installing weak'); | ||
require('child_process').exec('npm i --no-save --silent weak@1.0.1', (err, stdout, stderr) => { | ||
if (err) { | ||
console.log('failed to install weak'); | ||
} else { | ||
test(); | ||
} | ||
run() | ||
.then(run) | ||
.then(() => { | ||
console.log('Success: No memory leak detected'); | ||
}) | ||
.catch(err => { | ||
console.error(err.message); | ||
process.exit(1); | ||
}); | ||
} |