public void BlockComment_In_One_Line() { const string text = " asdölfkj asdfj asdölkjfas asdflj /* asöldkfjasdfölkjhas dfhööhasdf */ hö\r\nas dlfjhas dflasd fasdlkfh "; var lex = new Lexer(text) {Matches = Helper.SplitText(text) }; lex.EatComments(); Assert.AreEqual(1, lex.Tokens.Count); Assert.AreEqual(0, lex.Errors.Count); Assert.AreEqual(0, lex.Index); Assert.AreEqual(10, lex.Matches.Count); Assert.AreEqual(35, lex.Tokens[0].Position); Assert.AreEqual(36, lex.Tokens[0].Length); Assert.AreEqual(0, lex.Line); }
public void LineComment_until_EOF() { const string text = " option farz = true; // this is a comment until EOF"; var lex = new Lexer(text) {Matches = Helper.SplitText(text) }; lex.EatComments(); Assert.AreEqual(1, lex.Tokens.Count); Assert.AreEqual(0, lex.Errors.Count); Assert.AreEqual(0, lex.Index); Assert.AreEqual(5, lex.Matches.Count); Assert.AreEqual(23, lex.Tokens[0].Position); Assert.AreEqual(30, lex.Tokens[0].Length); Assert.AreEqual(0, lex.Line); }
public void LineComment_without_EOF2() { const string text = " option farz = true; // this is a comment until end of line\r\n message..."; var lex = new Lexer(text) { Matches = Helper.SplitText(text) }; lex.EatComments(); Assert.AreEqual(1, lex.Tokens.Count); Assert.AreEqual(0, lex.Errors.Count); Assert.AreEqual(0, lex.Index); Assert.AreEqual(10, lex.Matches.Count); Assert.AreEqual(22, lex.Tokens[0].Position); Assert.AreEqual(38, lex.Tokens[0].Length); Assert.AreEqual(0, lex.Line); }
public void BlockComment_Over_Multiple_Lines_Until_EOF_Missing_EndComment() { const string text = " asdölfkj asdfj asdölkjfas asdflj /* asöldkfjasdfölkjhas\r\n dfhöö \r\nhasdf"; var lex = new Lexer(text) {Matches = Helper.SplitText(text) }; lex.EatComments(); Assert.AreEqual(1, lex.Tokens.Count); Assert.AreEqual(1, lex.Errors.Count); Assert.AreEqual(0, lex.Index); Assert.AreEqual(4, lex.Matches.Count); Assert.AreEqual(35, lex.Tokens[0].Position); Assert.AreEqual(38, lex.Tokens[0].Length); Assert.AreEqual(0, lex.Errors[0].Line); Assert.AreEqual(1, lex.Errors[0].Length); Assert.AreEqual(73, lex.Errors[0].Position); Assert.AreEqual(0, lex.Line); }