Skip to content

Commit

Permalink
Merge 460dfd1 into 6ffd4d1
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Apr 24, 2018
2 parents 6ffd4d1 + 460dfd1 commit 1678f38
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/moduleEnv.js
Expand Up @@ -42,7 +42,7 @@ var moduleWrapper0 = Module.wrapper[0],
// However, since most projects have a seperate linting step which catches these const re-assignment
// errors anyway, it's probably still a reasonable trade-off.
// Test the regular expresssion at https://regex101.com/r/dvnZPv/2 and also check out testLib/constModule.js.
matchConst = /(^|\s|\}|;)const(\/\*|\s)/gm,
matchConst = /(^|\s|\}|;)const(\/\*|\s|{)/gm,
nodeRequire,
currentModule;

Expand Down
4 changes: 4 additions & 0 deletions testLib/constModule.js
Expand Up @@ -9,6 +9,7 @@ const
g = "g";
const/*wtf this is valid*/h = "h";
const /*and this is also*/i = "i";
const{k} = {k: "k"};

exports.a = function () {
return a;
Expand Down Expand Up @@ -40,3 +41,6 @@ exports.i = function () {
exports.j = function () {
return j;
};
exports.k = function () {
return k;
};
9 changes: 6 additions & 3 deletions testLib/sharedTestCases.js
Expand Up @@ -388,10 +388,13 @@ module.exports = function () {

it("should be possible to set a const variable", function () {
var constModule = rewire("./constModule");
var varNames = Object.keys(constModule);

"abcdefghij".split("").forEach(letter => {
constModule.__set__(letter, "this has been changed"); // should not throw
expect(constModule[letter]()).to.equal("this has been changed");
expect(varNames.length).to.be.greaterThan(0);

varNames.forEach(varName => {
constModule.__set__(varName, "this has been changed"); // should not throw
expect(constModule[varName]()).to.equal("this has been changed");
});
});

Expand Down

0 comments on commit 1678f38

Please sign in to comment.