Skip to content

Commit

Permalink
Move comments tests into their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuk committed Feb 10, 2018
1 parent 18ca4ab commit 67a3178
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
26 changes: 26 additions & 0 deletions test/comment/index.js
@@ -0,0 +1,26 @@
console.log("comments");

/*
foo
require("./should-not-load");
bar
*/

// require("./should-not-load");
function $require() {}
function _require() {}
function irequire() {}
var o = {require: function(){}};

$require("./should-not-load");
_require("./should-not-load");
irequire("./should-not-load");
o.require("./should-not-load");

// this is still problematic if uncommented:
// console.log('require("./should-not-load")')

assert(
(require)("./should-not-load") !== 4,
"Should not load modules from commented out code and lookalikes"
);
1 change: 1 addition & 0 deletions test/comment/should-not-load.js
@@ -0,0 +1 @@
module.exports = 4
6 changes: 5 additions & 1 deletion test/index.html
Expand Up @@ -12,7 +12,11 @@
}
</script>
<script type="text/javascript">
R("./index", console.warn.bind(console));
R("./index", function (error) {
if (error) {
throw error;
}
});

R(function (require, exports, module) {
console.log("module");
Expand Down
26 changes: 1 addition & 25 deletions test/index.js
Expand Up @@ -13,28 +13,4 @@ require("dep/index");

require("./multi-require/index");

console.log("should not load");
/*
foo
require("./should-not-load");
bar
*/

// require("./should-not-load");
function $require() {}
function _require() {}
function irequire() {}
var o = {require: function(){}};

$require("./should-not-load");
_require("./should-not-load");
irequire("./should-not-load");
o.require("./should-not-load");

// this is still problematic if uncommented:
// console.log('require("./should-not-load")')

assert(
eval('requ' + 'ire("./should-not-load")') !== 4,
"Should not load modules from commented out code and lookalikes"
);
require("./comment/index");
1 change: 0 additions & 1 deletion test/should-not-load.js

This file was deleted.

0 comments on commit 67a3178

Please sign in to comment.