Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/fourslash/_scripts/convertFourslash.mts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,9 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V
else if (strArg = parseBaselineMarkerOrRangeArg(arg)) {
newArgs.push(strArg);
}
else if (arg.getText() === "test.markers()") {
newArgs.push("ToAny(f.Markers())...");
}
else {
console.error(`Unrecognized argument in verify.baselineDocumentHighlights: ${arg.getText()}`);
return undefined;
Expand Down
1 change: 0 additions & 1 deletion internal/fourslash/_scripts/crashingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ TestFindReferencesBindingPatternInJsdocNoCrash1
TestFindReferencesBindingPatternInJsdocNoCrash2
TestFormatDocumentWithTrivia
TestFormattingJsxTexts4
TestGetOccurrencesIfElseBroken
TestImportNameCodeFix_importType8
TestQuickInfoBindingPatternInJsdocNoCrash1
1 change: 0 additions & 1 deletion internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ TestGetJavaScriptQuickInfo6
TestGetJavaScriptQuickInfo7
TestGetJavaScriptQuickInfo8
TestGetJavaScriptSyntacticDiagnostics24
TestGetOccurrencesIfElseBroken
TestHoverOverComment
TestImportFixesGlobalTypingsCache
TestImportMetaCompletionDetails
Expand Down
28 changes: 28 additions & 0 deletions internal/fourslash/tests/gen/getOccurrencesConst02_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGetOccurrencesConst02(t *testing.T) {
fourslash.SkipIfFailing(t)
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `module m {
declare /*1*/const x;
declare [|const|] enum E {
}
}

declare /*2*/const x;
declare [|const|] enum E {
}`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...)
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Markers())...)
}
28 changes: 28 additions & 0 deletions internal/fourslash/tests/gen/getOccurrencesConst03_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGetOccurrencesConst03(t *testing.T) {
fourslash.SkipIfFailing(t)
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `module m {
export /*1*/const x;
export [|const|] enum E {
}
}

export /*2*/const x;
export [|const|] enum E {
}`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...)
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Markers())...)
}
39 changes: 39 additions & 0 deletions internal/fourslash/tests/gen/getOccurrencesIfElse4_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGetOccurrencesIfElse4(t *testing.T) {
fourslash.SkipIfFailing(t)
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `if (true) {
if (false) {
}
else {
}
if (true) {
}
else {
/*1*/if (false)
/*2*/i/*3*/f (true)
var x = undefined;
}
}
else if (null) {
}
else /* whar garbl */ if (undefined) {
}
else
if (false) {
}
else { }`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Markers())...)
}
39 changes: 39 additions & 0 deletions internal/fourslash/tests/gen/getOccurrencesIfElse5_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGetOccurrencesIfElse5(t *testing.T) {
fourslash.SkipIfFailing(t)
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `if/*1*/ (true) {
if/*2*/ (false) {
}
else/*3*/ {
}
if/*4*/ (true) {
}
else/*5*/ {
if/*6*/ (false)
if/*7*/ (true)
var x = undefined;
}
}
else/*8*/ if (null) {
}
else/*9*/ /* whar garbl */ if/*10*/ (undefined) {
}
else/*11*/
if/*12*/ (false) {
}
else/*13*/ { }`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Markers())...)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGetOccurrencesLoopBreakContinue6(t *testing.T) {
fourslash.SkipIfFailing(t)
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `var arr = [1, 2, 3, 4];
label1: for (var n in arr) {
break;
continue;
break label1;
continue label1;

label2: for (var i = 0; i < arr[n]; i++) {
break label1;
continue label1;

break;
continue;
break label2;
continue label2;

function foo() {
label3: while (true) {
break;
continue;
break label3;
continue label3;

// these cross function boundaries
br/*1*/eak label1;
cont/*2*/inue label1;
bre/*3*/ak label2;
c/*4*/ontinue label2;

label4: do {
break;
continue;
break label4;
continue label4;

break label3;
continue label3;

switch (10) {
case 1:
case 2:
break;
break label4;
default:
continue;
}

// these cross function boundaries
br/*5*/eak label1;
co/*6*/ntinue label1;
br/*7*/eak label2;
con/*8*/tinue label2;
() => { b/*9*/reak; }
} while (true)
}
}
}
}

label5: while (true) break label5;

label7: while (true) co/*10*/ntinue label5;`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Markers())...)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGetOccurrencesLoopBreakContinueNegatives(t *testing.T) {
fourslash.SkipIfFailing(t)
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `var arr = [1, 2, 3, 4];
label1: for (var n in arr) {
break;
continue;
break label1;
continue label1;

label2: for (var i = 0; i < arr[n]; i++) {
break label1;
continue label1;

break;
continue;
break label2;
continue label2;

function foo() {
label3: while (true) {
break;
continue;
break label3;
continue label3;

// these cross function boundaries
br/*1*/eak label1;
cont/*2*/inue label1;
bre/*3*/ak label2;
c/*4*/ontinue label2;

label4: do {
break;
continue;
break label4;
continue label4;

break label3;
continue label3;

switch (10) {
case 1:
case 2:
break;
break label4;
default:
continue;
}

// these cross function boundaries
br/*5*/eak label1;
co/*6*/ntinue label1;
br/*7*/eak label2;
con/*8*/tinue label2;
() => { b/*9*/reak; }
} while (true)
}
}
}
}

label5: while (true) break label5;

label7: while (true) co/*10*/ntinue label5;`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Markers())...)
}
36 changes: 36 additions & 0 deletions internal/fourslash/tests/gen/getOccurrencesReturn4_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGetOccurrencesReturn4(t *testing.T) {
fourslash.SkipIfFailing(t)
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `function f(a: number) {
if (a > 0) {
return (function () {
return/*1*/;
return/*2*/;
return/*3*/;

if (false) {
return/*4*/ true;
}
})() || true;
}

var unusued = [1, 2, 3, 4].map(x => { return/*5*/ 4 })

return/*6*/;
return/*7*/ true;
}`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Markers())...)
}
Loading