mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-29 19:42:39 -05:00
Add tests and simplify existing ones
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I {}
|
||||
//// [|class C extends I|]{}
|
||||
|
||||
verify.rangeAfterCodeFix("class C implements I");
|
||||
@@ -1,6 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {}
|
||||
//// [|class c1 extends I1|]{}
|
||||
|
||||
verify.rangeAfterCodeFix("class c1 implements I1");
|
||||
@@ -1,6 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////interface I1 {}
|
||||
////[|class c1<T extends string , U> extends I1|]{}
|
||||
|
||||
verify.rangeAfterCodeFix("class c1<T extends string , U> implements I1");
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////interface I<X> { x: X}
|
||||
////[|class C<T extends string , U> extends I<T>|]{}
|
||||
|
||||
verify.rangeAfterCodeFix("class C<T extends string , U> implements I<T>");
|
||||
@@ -1,9 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I { }
|
||||
//// class C extends I { }
|
||||
|
||||
verify.fileAfterCodeFix(`
|
||||
interface I { }
|
||||
class C implements I { }
|
||||
`);
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// abstract x: number;
|
||||
//// }
|
||||
////
|
||||
//// class C3 implements C2 {[| |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
x: number;
|
||||
`);
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// class A {
|
||||
//// f() {}
|
||||
//// }
|
||||
////
|
||||
//// class B implements A {[| |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
f(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,10 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// f1(){}
|
||||
//// class C1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// abstract class C2 extends C1 {
|
||||
//// class C2 extends C1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// x: number;
|
||||
//// }
|
||||
//// interface I2 {
|
||||
//// x: number;
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements I1,I2 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
x: number;
|
||||
`);
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// abstract f1<T extends number>();
|
||||
//// }
|
||||
////
|
||||
//// abstract class C2 extends C1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// class C3 implements C2 {[|
|
||||
//// |]f2(){}
|
||||
//// }
|
||||
|
||||
verify.rangeAfterCodeFix(`f1<T extends number>(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// abstract f1<T extends number>();
|
||||
//// }
|
||||
////
|
||||
//// interface I1 extends C1 {}
|
||||
////
|
||||
//// class C2 implements I1 {[|
|
||||
////
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1<T extends number>(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// abstract f1<T>();
|
||||
//// }
|
||||
////
|
||||
//// abstract class C2 extends C1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// class C3 implements C2 {[|
|
||||
//// |]f2(){}
|
||||
//// }
|
||||
|
||||
verify.rangeAfterCodeFix(`f1<T>(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// abstract f1();
|
||||
//// }
|
||||
////
|
||||
//// abstract class C2 extends C1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// class C3 implements C2 {[|
|
||||
//// |]f2(){}
|
||||
//// }
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// namespace N1 {
|
||||
//// export interface I1 {
|
||||
//// f1();
|
||||
//// }
|
||||
//// }
|
||||
//// interface I1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements N1.I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,14 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// f1(){}
|
||||
//// }
|
||||
////
|
||||
//// class C2 implements C1 {[|
|
||||
//// |]f2(){}
|
||||
//// }
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,17 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// f1()
|
||||
//// }
|
||||
////
|
||||
//// interface I2 extends I1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements I2 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,19 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// interface I2 extends I1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// interface I3 extends I2 {}
|
||||
////
|
||||
//// class C1 implements I3 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,19 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// interface I2 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// interface I3 extends I2, I1 {}
|
||||
////
|
||||
//// class C1 implements I3 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,19 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// interface I2 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// interface I3 extends I2, I1 {}
|
||||
////
|
||||
//// class C1 implements I3 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,15 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// f1<T extends string>(x: number, y: C2);
|
||||
//// }
|
||||
////
|
||||
//// class C2 {}
|
||||
////
|
||||
//// class C1 implements I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1<T extends string>(x: number,y: C2){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,15 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// f1<T>(x: number, y: C2);
|
||||
//// }
|
||||
////
|
||||
//// class C2 {}
|
||||
////
|
||||
//// class C1 implements I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1<T>(x: number,y: C2){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// namespace N1 {
|
||||
//// export interface I1 {
|
||||
//// f1()
|
||||
//// }
|
||||
//// }
|
||||
//// interface I1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements N1.I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// namespace N1 {
|
||||
//// export interface I1 {
|
||||
//// f1(x: number, y: string)
|
||||
//// }
|
||||
//// }
|
||||
//// interface I1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements N1.I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(x: number,y: string){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,15 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// f1(x: number, y: T);
|
||||
//// }
|
||||
////
|
||||
//// class T {}
|
||||
////
|
||||
//// class C1 implements I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(x: number,y: T){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,14 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// interface I2 extends I1 {
|
||||
//// interface I {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements I2 {[|
|
||||
//// class C implements I {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I {
|
||||
//// f(x: number, y: string)
|
||||
//// }
|
||||
////
|
||||
//// class C implements I {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
f(x: number,y: string){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// namespace N1 {
|
||||
//// export interface I1 {
|
||||
//// x: number
|
||||
//// }
|
||||
//// }
|
||||
//// interface I1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements N1.I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`x: number;
|
||||
`);
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// x: number;
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`x: number;
|
||||
`);
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// x: number & { __iBrand: any };
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
x: number & { __iBrand: any }
|
||||
`);
|
||||
@@ -12,5 +12,6 @@
|
||||
//// class C1 implements N1.I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`x: number;
|
||||
verify.rangeAfterCodeFix(`
|
||||
x: number;
|
||||
`);
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I {
|
||||
//// x: number;
|
||||
//// y: number;
|
||||
//// }
|
||||
////
|
||||
//// class C2 implements C {[| |]
|
||||
//// x: number
|
||||
//// }
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
y: number;
|
||||
`);
|
||||
@@ -1,14 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// abstract class C1 {
|
||||
//// abstract f1<T extends number>();
|
||||
//// interface I {
|
||||
//// f1<T extends number>();
|
||||
//// }
|
||||
////
|
||||
//// class C2 extends C1 {[|
|
||||
////
|
||||
//// |]}
|
||||
//// class C implements I {[| |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1<T extends number>(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
`);
|
||||
@@ -1,22 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// class C1 {
|
||||
//// f1();
|
||||
//// }
|
||||
////
|
||||
//// class C2 {
|
||||
//// f2();
|
||||
//// }
|
||||
////
|
||||
//// interface I1 extends C1, C2 {}
|
||||
////
|
||||
//// class C3 implements I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`f1(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
f2(){
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// x: number;
|
||||
//// }
|
||||
//// interface I2 {
|
||||
//// y: number;
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements I1,I2 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
x: number;
|
||||
y: number;
|
||||
`);
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I1 {
|
||||
//// x: number,
|
||||
//// y: number
|
||||
//// z: number;
|
||||
//// f(),
|
||||
//// g()
|
||||
//// h();
|
||||
//// }
|
||||
////
|
||||
//// class C1 implements I1 {[|
|
||||
//// |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
f() {
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
g() {
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
h() {
|
||||
throw new Error('Method not Implemented');
|
||||
}
|
||||
`);
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I<T> {
|
||||
//// x: { y: T, z: T[] };
|
||||
//// }
|
||||
////
|
||||
//// class C implements I<number> { }
|
||||
|
||||
verify.fileAfterCodeFix(`
|
||||
interface I<T> {
|
||||
x: { y: T, z: T[] };
|
||||
}
|
||||
|
||||
class C<number> implements I<number> {
|
||||
x: { y: number, z: number[] };
|
||||
}
|
||||
`);
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I<T extends string> {
|
||||
//// x: T;
|
||||
//// }
|
||||
////
|
||||
//// class C implements I<number> { }
|
||||
|
||||
// Don't know how to instantiate in codeFix
|
||||
// if instantiation is invalid.
|
||||
verify.not.codeFixAvailable();
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I<T> {
|
||||
//// x: T;
|
||||
//// }
|
||||
////
|
||||
//// class C implements I<number> { }
|
||||
|
||||
verify.fileAfterCodeFix(`
|
||||
interface I<T> {
|
||||
x: T;
|
||||
}
|
||||
|
||||
class C implements I<number> {
|
||||
x: number;
|
||||
}
|
||||
`);
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I<T> {
|
||||
//// x: T;
|
||||
//// }
|
||||
////
|
||||
//// class C<T> implements I<T> { }
|
||||
|
||||
verify.fileAfterCodeFix(`
|
||||
interface I<T> {
|
||||
x: T;
|
||||
}
|
||||
|
||||
class C<T> implements I<T> {
|
||||
x: T;
|
||||
}
|
||||
`);
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I<T> {
|
||||
//// x: T;
|
||||
//// }
|
||||
////
|
||||
//// class C<U> implements I<U> { }
|
||||
|
||||
verify.fileAfterCodeFix(`
|
||||
interface I<T> {
|
||||
x: T;
|
||||
}
|
||||
|
||||
class C<U> implements I<U> {
|
||||
x: U;
|
||||
}
|
||||
`);
|
||||
@@ -0,0 +1,9 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I<T> {
|
||||
//// x: T;
|
||||
//// }
|
||||
////
|
||||
//// class C implements I { }
|
||||
|
||||
verify.not.codeFixAvailable();
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I {
|
||||
//// x: T;
|
||||
//// }
|
||||
////
|
||||
//// class C implements I { }
|
||||
|
||||
// T is not a declared symbol. There are a couple fixes:
|
||||
// 1) Declare T.
|
||||
// 2) Rename T to an existing symbol.
|
||||
// 3) Make T a type parameter to I.
|
||||
//
|
||||
// In the latter two cases, it is premature to copy `x:T` into C.
|
||||
// Since we can't guess the programmer's intent here, we do nothing.
|
||||
verify.not.codeFixAvailable();
|
||||
Reference in New Issue
Block a user