Add tests and simplify existing ones

This commit is contained in:
Arthur Ozga
2016-11-04 16:34:10 -07:00
parent 3b0b696517
commit 36c5befae9
51 changed files with 261 additions and 332 deletions

View File

@@ -0,0 +1,6 @@
/// <reference path='fourslash.ts' />
//// interface I {}
//// [|class C extends I|]{}
verify.rangeAfterCodeFix("class C implements I");

View File

@@ -1,6 +0,0 @@
/// <reference path='fourslash.ts' />
//// interface I1 {}
//// [|class c1 extends I1|]{}
verify.rangeAfterCodeFix("class c1 implements I1");

View File

@@ -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");

View File

@@ -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>");

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
//// interface I { }
//// class C extends I { }
verify.fileAfterCodeFix(`
interface I { }
class C implements I { }
`);

View File

@@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
//// abstract class C1 {
//// abstract x: number;
//// }
////
//// class C3 implements C2 {[| |]}
verify.rangeAfterCodeFix(`
x: number;
`);

View File

@@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />
//// class A {
//// f() {}
//// }
////
//// class B implements A {[| |]}
verify.rangeAfterCodeFix(`
f(){
throw new Error('Method not Implemented');
}
`);

View File

@@ -1,10 +1,10 @@
/// <reference path='fourslash.ts' />
//// abstract class C1 {
//// f1(){}
//// class C1 {
//// f1();
//// }
////
//// abstract class C2 extends C1 {
//// class C2 extends C1 {
////
//// }
////

View File

@@ -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;
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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');
}
`);

View File

@@ -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(){

View File

@@ -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');
}
`);

View File

@@ -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;
`);

View File

@@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
//// interface I1 {
//// x: number;
//// }
////
//// class C1 implements I1 {[|
//// |]}
verify.rangeAfterCodeFix(`x: number;
`);

View File

@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts' />
//// interface I1 {
//// x: number & { __iBrand: any };
//// }
////
//// class C1 implements I1 {[|
//// |]}
verify.rangeAfterCodeFix(`
x: number & { __iBrand: any }
`);

View File

@@ -12,5 +12,6 @@
//// class C1 implements N1.I1 {[|
//// |]}
verify.rangeAfterCodeFix(`x: number;
verify.rangeAfterCodeFix(`
x: number;
`);

View File

@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts' />
//// interface I {
//// x: number;
//// y: number;
//// }
////
//// class C2 implements C {[| |]
//// x: number
//// }
verify.rangeAfterCodeFix(`
y: number;
`);

View File

@@ -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');
}
`);
`);

View File

@@ -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');
}
`);

View File

@@ -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;
`);

View File

@@ -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');
}
`);

View File

@@ -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[] };
}
`);

View File

@@ -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();

View File

@@ -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;
}
`);

View File

@@ -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;
}
`);

View File

@@ -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;
}
`);

View File

@@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
//// interface I<T> {
//// x: T;
//// }
////
//// class C implements I { }
verify.not.codeFixAvailable();

View File

@@ -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();