Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5823b27

Browse files
Update comment test to use exact string comparisons and test second formatting pass
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
1 parentbb3aa82 commit5823b27

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

‎internal/format/comment_test.go

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package format_test
22

33
import (
4-
"strings"
54
"testing"
65

76
"github.com/microsoft/typescript-go/internal/ast"
@@ -46,16 +45,33 @@ func TestCommentFormatting(t *testing.T) {
4645
edits:=format.FormatDocument(ctx,sourceFile)
4746
firstFormatted:=applyBulkEdits(originalText,edits)
4847

49-
// Verify that the comment and async keyword are preserved
50-
assert.Assert(t,strings.Contains(firstFormatted,"/**"))
51-
assert.Assert(t,strings.Contains(firstFormatted,"*/"))
52-
assert.Assert(t,strings.Contains(firstFormatted,"async"))
53-
assert.Assert(t,!strings.Contains(firstFormatted," /\n"))// Should not have broken comment
54-
55-
// The main issue is fixed - the comment is preserved correctly
56-
// Let's not test the second formatting for now as it might have separate issues
57-
// assert.Assert(t, strings.Contains(secondFormatted, "async"))
58-
// assert.Assert(t, !strings.Contains(secondFormatted, " /\n")) // Should not have broken comment
59-
// assert.Assert(t, !strings.Contains(secondFormatted, "sync x()")) // Should not have corrupted async keyword
48+
// Expected output after first formatting
49+
expectedFirstFormatted:=`class C {
50+
/**
51+
*
52+
*/
53+
async x() { }
54+
} `
55+
56+
assert.Equal(t,expectedFirstFormatted,firstFormatted)
57+
58+
// Apply formatting a second time to test stability
59+
sourceFile2:=parser.ParseSourceFile(ast.SourceFileParseOptions{
60+
FileName:"/test.ts",
61+
Path:"/test.ts",
62+
},firstFormatted,core.ScriptKindTS)
63+
64+
edits2:=format.FormatDocument(ctx,sourceFile2)
65+
secondFormatted:=applyBulkEdits(firstFormatted,edits2)
66+
67+
// Test that second formatting is stable or document what it produces
68+
expectedSecondFormatted:=`class C {
69+
/**
70+
*
71+
*/
72+
async x() { }
73+
} `
74+
75+
assert.Equal(t,expectedSecondFormatted,secondFormatted)
6076
})
6177
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp