Skip to content

Commit 36b612e

Browse files
committed
Add failing tests
1 parent c1a3676 commit 36b612e

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

test/configCases/parsing/harmony-this/abc.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
function returnThis() {
2-
if(typeof this === "undefined") return "undefined";
2+
if (typeof this === "undefined") return "undefined";
33
return this;
44
}
55

66
var a = returnThis;
77
var b = returnThis;
88

9-
export {
10-
a,
11-
b
12-
}
9+
export { a, b };
1310

1411
export const that = this;
1512
export const returnThisArrow = () => this;
@@ -29,10 +26,38 @@ export class C {
2926

3027
export const extendThisClass = () => {
3128
return class extends this.Buffer {};
32-
}
29+
};
3330

3431
export function D() {
3532
this.prop = () => "ok";
3633
}
3734

35+
// See https://github.com/webpack/webpack/issues/6379
36+
export const E = {
37+
x: "bar",
38+
foo(x = this.x) {
39+
return x;
40+
}
41+
};
42+
43+
// See https://github.com/webpack/webpack/issues/6967
44+
export const F = function() {
45+
return this;
46+
}.call("ok");
47+
48+
export function f1(x = this.x) {
49+
return x;
50+
}
51+
52+
export const f2 = function(x = this.x) {
53+
return x;
54+
};
55+
56+
export const f3 = (x = this) => x;
57+
58+
export function G(x) {
59+
this.x = x;
60+
this.getX = (y = this.x) => y;
61+
}
62+
3863
export default returnThis;

test/configCases/parsing/harmony-this/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use strict";
22

3-
import d, {a, b as B, C as _C, D as _D, extendThisClass, returnThisArrow, returnThisMember, that} from "./abc";
3+
import should from "should";
4+
import {extendThisClass, returnThisArrow, returnThisMember, that} from "./abc";
5+
import d, {a, b as B, C as _C, D as _D, E, F, f1, f2, f3, G} from "./abc";
46

57
import * as abc from "./abc";
68

@@ -24,6 +26,13 @@ it("should not break classes and functions", function() {
2426
(new _C).foo().should.be.eql("bar");
2527
(new _C).bar().should.be.eql("bar");
2628
(new _D).prop().should.be.eql("ok");
29+
E.foo().should.be.eql("bar");
30+
F.should.be.eql("ok");
31+
f1.call({x: "f1"}).should.be.eql("f1");
32+
f2.call({x: "f2"}).should.be.eql("f2");
33+
should(f3.call("f3")).be.eql(undefined);
34+
should(f3()).be.eql(undefined);
35+
(new G("ok")).getX().should.be.eql("ok");
2736
});
2837

2938
function x() { throw new Error("should not be executed"); }

0 commit comments

Comments
 (0)