87 lines
2.1 KiB
Go
87 lines
2.1 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 TestThisPredicateFunctionCompletions02(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
|
const content = `interface Sundries {
|
|
broken: boolean;
|
|
}
|
|
|
|
interface Supplies {
|
|
spoiled: boolean;
|
|
}
|
|
|
|
interface Crate<T> {
|
|
contents: T;
|
|
isSundries(): this is Crate<Sundries>;
|
|
isSupplies(): this is Crate<Supplies>;
|
|
isPackedTight(): this is (this & {extraContents: T});
|
|
}
|
|
const crate: Crate<any>;
|
|
if (crate.isPackedTight()) {
|
|
crate./*1*/;
|
|
}
|
|
if (crate.isSundries()) {
|
|
crate.contents./*2*/;
|
|
if (crate.isPackedTight()) {
|
|
crate./*3*/;
|
|
}
|
|
}
|
|
if (crate.isSupplies()) {
|
|
crate.contents./*4*/;
|
|
if (crate.isPackedTight()) {
|
|
crate./*5*/;
|
|
}
|
|
}`
|
|
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
|
f.VerifyCompletions(t, []string{"1", "3", "5"}, &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Exact: []fourslash.CompletionsExpectedItem{
|
|
"contents",
|
|
"extraContents",
|
|
"isPackedTight",
|
|
"isSundries",
|
|
"isSupplies",
|
|
},
|
|
},
|
|
})
|
|
f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Exact: []fourslash.CompletionsExpectedItem{
|
|
"broken",
|
|
},
|
|
},
|
|
})
|
|
f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Exact: []fourslash.CompletionsExpectedItem{
|
|
"spoiled",
|
|
},
|
|
},
|
|
})
|
|
}
|