vendor tsgo
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
// Code generated by convertFourslash; DO NOT EDIT.
|
||||
// To modify this test, run "npm run makemanual genericRespecialization1"
|
||||
|
||||
package fourslash_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/microsoft/typescript-go/internal/fourslash"
|
||||
"github.com/microsoft/typescript-go/internal/testutil"
|
||||
)
|
||||
|
||||
func TestGenericRespecialization1(t *testing.T) {
|
||||
fourslash.SkipIfFailing(t)
|
||||
t.Parallel()
|
||||
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
||||
const content = `// @strict: false
|
||||
class Food {
|
||||
private amount: number;
|
||||
constructor(public name: string) {
|
||||
this.amount = 100;
|
||||
}
|
||||
public eat(amountToEat: number): boolean {
|
||||
this.amount -= amountToEat;
|
||||
if (this.amount <= 0) {
|
||||
this.amount = 0;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
class IceCream extends Food {
|
||||
private isDairyFree: boolean;
|
||||
constructor(public flavor: string) {
|
||||
super("Ice Cream");
|
||||
}
|
||||
}
|
||||
class Cookie extends Food {
|
||||
constructor(public flavor: string, public isGlutenFree: boolean) {
|
||||
super("Cookie");
|
||||
}
|
||||
}
|
||||
class Slug {
|
||||
// This is NOT a food!!!
|
||||
}
|
||||
class GenericMonster<T extends Food, V> {
|
||||
private name: string;
|
||||
private age: number;
|
||||
private isFriendly: boolean;
|
||||
constructor(name: string, age: number, isFriendly: boolean, private food: T, public variant: V) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.isFriendly = isFriendly;
|
||||
}
|
||||
public getFood(): T {
|
||||
return this.food;
|
||||
}
|
||||
public getVariant(): V {
|
||||
return this.variant;
|
||||
}
|
||||
public eatFood(amountToEat: number): boolean {
|
||||
return this.food.eat(amountToEat);
|
||||
}
|
||||
public sayGreeting(): string {
|
||||
return ("My name is " + this.name + ", and my age is " + this.age + ". I enjoy eating " + this.food.name + " and my variant is " + this.variant);
|
||||
}
|
||||
}
|
||||
class GenericPlanet<T extends GenericMonster</*2*/Cookie, any>> {
|
||||
constructor(public name: string, public solarSystem: string, public species: T) { }
|
||||
}
|
||||
var cookie = new Cookie("Chocolate Chip", false);
|
||||
var cookieMonster = new GenericMonster<Cookie, string>("Cookie Monster", 50, true, cookie, "hello");
|
||||
var sesameStreet = new GenericPlanet<GenericMonster<Cookie, string>>("Sesame Street", "Alpha Centuri", cookieMonster);
|
||||
class GenericPlanet2<T extends Food, V>{
|
||||
constructor(public name: string, public solarSystem: string, public species: GenericMonster<T, V>) { }
|
||||
}
|
||||
/*1*/`
|
||||
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
||||
defer done()
|
||||
f.VerifyNoErrors(t)
|
||||
f.GoToMarker(t, "1")
|
||||
f.InsertLine(t, "")
|
||||
f.InsertLine(t, "")
|
||||
f.VerifyNoErrors(t)
|
||||
f.GoToMarker(t, "2")
|
||||
f.DeleteAtCaret(t, 6)
|
||||
f.Insert(t, "any")
|
||||
f.VerifyNoErrors(t)
|
||||
f.InsertLine(t, "var narnia = new GenericPlanet2<Cookie, string>(")
|
||||
}
|
||||
Reference in New Issue
Block a user