fix(lexer): treat trailing CR as line end so comment text is idempotent
Test / test (push) Successful in 2m13s
Test / test (push) Successful in 2m13s
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -85,6 +85,19 @@ func TestLabelAndComment(t *testing.T) {
|
||||
[]token.Kind{token.Ident, token.Colon, token.Ident, token.Ident, token.Comment})
|
||||
}
|
||||
|
||||
func TestLineCommentTrailingWhitespace(t *testing.T) {
|
||||
// A trailing run of CR, spaces and tabs is line-ending whitespace, not
|
||||
// comment content. The token text must not depend on what follows the
|
||||
// comment: before the trim covered only a CR directly before the token's
|
||||
// end, "// loop\r " kept the CR while "// loop\r\n" dropped it, and the
|
||||
// formatter re-lexed its own output to a shorter comment.
|
||||
eq(t, texts("// loop\r"), []string{"// loop"})
|
||||
eq(t, texts("// loop\r "), []string{"// loop"})
|
||||
eq(t, texts("// loop \r\t\nMOVQ AX, BX"), []string{"// loop", "MOVQ", "AX", ",", "BX"})
|
||||
// A CR inside the comment is content and stays.
|
||||
eq(t, texts("// loops\rall"), []string{"// loops\rall"})
|
||||
}
|
||||
|
||||
func TestAVX512Mnemonics(t *testing.T) {
|
||||
eq(t, texts("VFMADD231PD Z14, Z12, Z10"),
|
||||
[]string{"VFMADD231PD", "Z14", ",", "Z12", ",", "Z10"})
|
||||
|
||||
Reference in New Issue
Block a user