Skip to content

Commit c125f08

Browse files
author
Arthur Ozga
committed
add tests
1 parent f19c312 commit c125f08

File tree

5 files changed

+138
-3
lines changed

5 files changed

+138
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
6+
// @Filename: f2.js
7+
//// import * as X from "./f1";
8+
//// X.C.m0(1, "", []);
9+
//// X.C.x;
10+
//// let c = new X.C;
11+
//// c.m1();
12+
//// c.y = {};
13+
14+
// @Filename: f1.ts
15+
//// export class C {[|
16+
//// |]x: number;
17+
//// static y: string;
18+
//// }
19+
20+
verify.applyCodeFix(/*errorCode*/undefined, 0);
21+
verify.applyCodeFix(/*errorCode*/undefined, 0);
22+
verify.applyCodeFix(/*errorCode*/undefined, 0);
23+
verify.applyCodeFix(/*errorCode*/undefined, 0);
24+
25+
verify.rangeIs(`
26+
y: { [x: string]: any; };
27+
m1(): any {
28+
throw new Error("Method not implemented.");
29+
}
30+
static x: any;
31+
static m0(arg0: any, arg1: any, arg2: any): any {
32+
throw new Error("Method not implemented.");
33+
}
34+
`);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
6+
// @Filename: f2.ts
7+
//// import * as X from "./f1";
8+
//// X.C.m0(1, "", []);
9+
//// X.C.x;
10+
//// let c = new X.C;
11+
//// c.m1();
12+
//// c.y = {};
13+
14+
// @Filename: f1.js
15+
//// [|export class C {
16+
//// x: number;
17+
//// static y: string;
18+
//// constructor() { }
19+
//// }|]
20+
21+
verify.applyCodeFix(/*errorCode*/undefined, 0);
22+
verify.applyCodeFix(/*errorCode*/undefined, 0);
23+
verify.applyCodeFix(/*errorCode*/undefined, 0);
24+
verify.applyCodeFix(/*errorCode*/undefined, 0);
25+
26+
verify.rangeIs(`
27+
export class C {
28+
m1() {
29+
throw new Error("Method not implemented.");
30+
}
31+
static m0(arg0, arg1, arg2) {
32+
throw new Error("Method not implemented.");
33+
}
34+
x: number;
35+
static y: string;
36+
constructor() {
37+
this.y = undefined;
38+
}
39+
}
40+
`);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//// class A {[|
4+
//// |]static foo0() {
5+
//// this.m1(1,2,3);
6+
//// A.m2(1,2);
7+
//// this.prop1 = 10;
8+
//// A.prop2 = "asdf";
9+
//// }
10+
//// }
11+
12+
verify.applyCodeFix(/*errorCode*/undefined, 0);
13+
verify.applyCodeFix(/*errorCode*/undefined, 0);
14+
verify.applyCodeFix(/*errorCode*/undefined, 0);
15+
verify.applyCodeFix(/*errorCode*/undefined, 0);
16+
17+
verify.rangeIs(`
18+
static prop2: string;
19+
static prop1: number;
20+
static m2(arg0: any, arg1: any): any {
21+
throw new Error("Method not implemented.");
22+
}
23+
static m1(arg0: any, arg1: any, arg2: any): any {
24+
throw new Error("Method not implemented.");
25+
}
26+
`);
27+
28+
// class A {
29+
// static prop2: string;
30+
// static prop1: number;
31+
// static m2(arg0: any, arg1: any): any {
32+
// throw new Error("Method not implemented.");
33+
// }
34+
// static m1(arg0: any, arg1: any, arg2: any): any {
35+
// throw new Error("Method not implemented.");
36+
// }
37+
// static foo0() {
38+
// this.m1(1,2,3);
39+
// A.m2(1,2);
40+
// this.prop1 = 10;
41+
// A.prop2 = "asdf";
42+
// }
43+
// }
44+

tests/cases/fourslash/codeFixUndeclaredMethod.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ verify.applyCodeFix(/*errorCode*/undefined, 0);
1515
verify.applyCodeFix(/*errorCode*/undefined, 0);
1616

1717
verify.rangeIs(`
18-
foo3<T0, T1, T2, T3, T4, T5, T6, T7>() {
18+
foo3<T0, T1, T2, T3, T4, T5, T6, T7>(): any {
1919
throw new Error("Method not implemented.");
2020
}
21-
foo2<T, U, V, W, X, Y, Z>() {
21+
foo2<T, U, V, W, X, Y, Z>(): any {
2222
throw new Error("Method not implemented.");
2323
}
24-
foo1(arg0: any, arg1: any, arg2: any) {
24+
foo1(arg0: any, arg1: any, arg2: any): any {
2525
throw new Error("Method not implemented.");
2626
}
2727
`);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//// interface I { x: number; }
4+
//// let i: I;
5+
//// i.y;
6+
//// i.foo();
7+
//// enum E { a,b }
8+
//// let e: typeof E;
9+
//// e.a;
10+
//// e.c;
11+
//// let obj = { a: 1, b: "asdf"};
12+
//// obj.c;
13+
//// type T<U> = I | U;
14+
//// let t: T<number>;
15+
//// t.x;
16+
17+
verify.not.codeFixAvailable();

0 commit comments

Comments
 (0)