88 lines
2.0 KiB
Go
88 lines
2.0 KiB
Go
package fourslash_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/fourslash"
|
|
. "efprojects.com/kitten-ipc/kitcom/internal/tsgo/fourslash/tests/util"
|
|
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil"
|
|
)
|
|
|
|
func TestThisPredicateFunctionCompletions03(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
|
const content = `class RoyalGuard {
|
|
isLeader(): this is LeadGuard {
|
|
return this instanceof LeadGuard;
|
|
}
|
|
isFollower(): this is FollowerGuard {
|
|
return this instanceof FollowerGuard;
|
|
}
|
|
}
|
|
|
|
class LeadGuard extends RoyalGuard {
|
|
lead(): void {};
|
|
}
|
|
|
|
class FollowerGuard extends RoyalGuard {
|
|
follow(): void {};
|
|
}
|
|
|
|
let a: RoyalGuard = new FollowerGuard();
|
|
if (a.is/*1*/Leader()) {
|
|
a./*2*/;
|
|
}
|
|
else if (a.is/*3*/Follower()) {
|
|
a./*4*/;
|
|
}
|
|
|
|
interface GuardInterface {
|
|
isLeader(): this is LeadGuard;
|
|
isFollower(): this is FollowerGuard;
|
|
}
|
|
|
|
let b: GuardInterface;
|
|
if (b.is/*5*/Leader()) {
|
|
b./*6*/;
|
|
}
|
|
else if (b.is/*7*/Follower()) {
|
|
b./*8*/;
|
|
}
|
|
|
|
let leader/*13*/Status = a.isLeader();
|
|
function isLeaderGuard(g: RoyalGuard) {
|
|
return g.isLeader();
|
|
}
|
|
let checked/*14*/LeaderStatus = isLeader/*15*/Guard(a);`
|
|
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
|
f.VerifyCompletions(t, []string{"2", "6"}, &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Unsorted: []fourslash.CompletionsExpectedItem{
|
|
"lead",
|
|
"isLeader",
|
|
"isFollower",
|
|
},
|
|
},
|
|
})
|
|
f.VerifyCompletions(t, []string{"4", "8"}, &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Unsorted: []fourslash.CompletionsExpectedItem{
|
|
"follow",
|
|
"isLeader",
|
|
"isFollower",
|
|
},
|
|
},
|
|
})
|
|
}
|