-
-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commonjs): add classBodyDepth flag (#1507)
- Loading branch information
Showing
5 changed files
with
48 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
module.exports = function augmentThis() { | ||
exports.augmentThis = function augmentThis() { | ||
this.x = 'x'; | ||
}; | ||
|
||
this.y = 'y'; | ||
|
||
exports.classThis = class classThis { | ||
constructor(){ | ||
class _classThis { | ||
y = 'yyy' | ||
yyy = this.y | ||
} | ||
this._instance = new _classThis() | ||
} | ||
y = 'yy' | ||
yy = this.y | ||
} |
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,7 +1,12 @@ | ||
const foo = require('./foo'); | ||
const { augmentThis, classThis } = require('./foo'); | ||
|
||
const obj = {}; | ||
foo.call(obj); | ||
augmentThis.call(obj); | ||
|
||
t.is(obj.x, 'x'); | ||
t.is(this.y, 'y'); | ||
|
||
const instance = new classThis(); | ||
|
||
t.is(instance.yy,'yy'); | ||
t.is(instance._instance.yyy,'yyy'); |
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
Binary file not shown.