Add tests and fix \n between comments
This commit is contained in:
@@ -513,6 +513,8 @@ static Token *ast_parse_multiline_string_literal(ParseContext *pc, Buf *buf) {
|
||||
// if not, we have to revert back to before the doc comment
|
||||
if (peek_token(pc)->id != TokenIdMultilineStringLiteral) {
|
||||
pc->current_token = cur_token;
|
||||
} else {
|
||||
buf_append_char(buf, '\n'); // Add a newline between comments
|
||||
}
|
||||
}
|
||||
return first_str_token;
|
||||
|
||||
@@ -166,6 +166,48 @@ test "multiline string" {
|
||||
expect(mem.eql(u8, s1, s2));
|
||||
}
|
||||
|
||||
test "multiline string comments at start" {
|
||||
const s1 =
|
||||
//\\one
|
||||
\\two)
|
||||
\\three
|
||||
;
|
||||
const s2 = "two)\nthree";
|
||||
expect(mem.eql(u8, s1, s2));
|
||||
}
|
||||
|
||||
test "multiline string comments at end" {
|
||||
const s1 =
|
||||
\\one
|
||||
\\two)
|
||||
//\\three
|
||||
;
|
||||
const s2 = "one\ntwo)";
|
||||
expect(mem.eql(u8, s1, s2));
|
||||
}
|
||||
|
||||
test "multiline string comments in middle" {
|
||||
const s1 =
|
||||
\\one
|
||||
//\\two)
|
||||
\\three
|
||||
;
|
||||
const s2 = "one\nthree";
|
||||
expect(mem.eql(u8, s1, s2));
|
||||
}
|
||||
|
||||
test "multiline string comments at multiple places" {
|
||||
const s1 =
|
||||
\\one
|
||||
//\\two
|
||||
\\three
|
||||
//\\four
|
||||
\\five
|
||||
;
|
||||
const s2 = "one\nthree\nfive";
|
||||
expect(mem.eql(u8, s1, s2));
|
||||
}
|
||||
|
||||
test "multiline C string" {
|
||||
const s1 =
|
||||
\\one
|
||||
|
||||
Reference in New Issue
Block a user