final receipt update

This commit is contained in:
EugeneTes
2026-01-22 11:09:38 +01:00
parent 9fbc61dede
commit fcb192b797
31 changed files with 2679 additions and 655 deletions

View File

@@ -216,4 +216,70 @@ Line 3";
}
#endregion
#region Comment lines should not produce empty lines
[Fact]
public void Tokenize_ConsecutiveCommentLines_ProduceNoNewLineTokens()
{
var lexer = new Lexer("@**@\n@**@\n@**@");
var result = lexer.Tokenize();
Assert.False(result.HasErrors);
// Should only have EOF token, no NewLine tokens for comment-only lines
Assert.DoesNotContain(result.Tokens, t => t.Type == TokenType.NewLine);
}
[Fact]
public void Tokenize_CommentLineBetweenContent_NoExtraNewLines()
{
var lexer = new Lexer("Line1\n@**@\nLine2");
var result = lexer.Tokenize();
Assert.False(result.HasErrors);
// Should have exactly 2 NewLine tokens (after Line1 and after Line2)
var newLineCount = result.Tokens.Count(t => t.Type == TokenType.NewLine);
Assert.Equal(2, newLineCount);
}
[Fact]
public void Tokenize_MultipleConsecutiveCommentLines_NoNewLines()
{
var lexer = new Lexer("Header\n@* comment 1 *@\n@* comment 2 *@\n@* comment 3 *@\nFooter");
var result = lexer.Tokenize();
Assert.False(result.HasErrors);
Assert.Contains(result.Tokens, t => t.Type == TokenType.Text && t.Value == "Header");
Assert.Contains(result.Tokens, t => t.Type == TokenType.Text && t.Value == "Footer");
// Should have exactly 2 NewLine tokens (after Header and after Footer)
var newLineCount = result.Tokens.Count(t => t.Type == TokenType.NewLine);
Assert.Equal(2, newLineCount);
}
[Fact]
public void Tokenize_EmptyLinesBetweenContent_ProducesNewLines()
{
var lexer = new Lexer("Line1\n\n\nLine2");
var result = lexer.Tokenize();
Assert.False(result.HasErrors);
// Should have 4 NewLine tokens (after Line1, after each empty line, after Line2)
var newLineCount = result.Tokens.Count(t => t.Type == TokenType.NewLine);
Assert.Equal(4, newLineCount);
}
[Fact]
public void Tokenize_EmptyLinesPreserved_CommentsRemoved()
{
var lexer = new Lexer("Header\n\n@* comment *@\n\nFooter");
var result = lexer.Tokenize();
Assert.False(result.HasErrors);
// Should have 4 NewLine tokens: after Header, after first empty line, after second empty line, after Footer
// The comment line should NOT produce a NewLine
var newLineCount = result.Tokens.Count(t => t.Type == TokenType.NewLine);
Assert.Equal(4, newLineCount);
}
#endregion
}