public void MoveNextLineReturnsLine() { string text = "This is a line \\ \r\nAnd this is next"; LookAheadTokenParser parser = new LookAheadTokenParser(TestUtil.GetTextStream(text), new string[] { }, false); Assert.AreEqual("This", parser.PeekNextToken()); Assert.AreEqual("This is a line \\ ", parser.MoveToNextLine()); Assert.AreEqual("And", parser.PeekNextToken()); }
public void PeekIsRepeatable() { string text = "&& ||"; LookAheadTokenParser parser = new LookAheadTokenParser(TestUtil.GetTextStream(text), new string[] { "&&", "||" }, true); Assert.AreEqual("&&", parser.PeekNextToken()); Assert.AreEqual("&&", parser.PeekNextToken()); Assert.AreEqual("&&", parser.PeekNextToken()); }
public void NewlineIsConsumed() { string text = "else\r\n" + "}\r\n}"; LookAheadTokenParser parser = new LookAheadTokenParser(TestUtil.GetTextStream(text), new string[] { }, true); Assert.AreEqual("else", parser.PeekNextToken()); Assert.AreEqual("else", parser.NextToken()); Assert.AreEqual("}", parser.PeekNextToken()); Assert.AreEqual("}", parser.NextToken()); Assert.AreEqual("}", parser.PeekNextToken()); Assert.AreEqual("}", parser.NextToken()); }
public void WhiteSpacesAreConsumed() { string text = "&& \r\n text ::{"; LookAheadTokenParser parser = new LookAheadTokenParser(TestUtil.GetTextStream(text), new string[] { "&&", "::", "{", " " }, true); Assert.AreEqual("&&", parser.PeekNextToken()); Assert.AreEqual("&&", parser.NextToken()); Assert.AreEqual("text", parser.PeekNextToken()); Assert.AreEqual("text", parser.NextToken()); Assert.AreEqual("::", parser.PeekNextToken()); Assert.AreEqual("::", parser.NextToken()); Assert.AreEqual("{", parser.PeekNextToken()); Assert.AreEqual("{", parser.NextToken()); }
public void EmptyStringThrows() { string text = ""; LookAheadTokenParser parser = new LookAheadTokenParser(TestUtil.GetTextStream(text), new string[] { }, true); parser.PeekNextToken(); }
public void OneTokenOnly() { string text = "text"; LookAheadTokenParser parser = new LookAheadTokenParser(TestUtil.GetTextStream(text), new string[] { }, true); Assert.AreEqual("text", parser.PeekNextToken()); Assert.AreEqual("text", parser.NextToken()); }
public void MoveToNextLine() { string text = "&& || somecrap \r\n" + "text"; LookAheadTokenParser parser = new LookAheadTokenParser(TestUtil.GetTextStream(text), new string[] { "&&", "||" }, true); Assert.AreEqual("&&", parser.NextToken()); Assert.AreEqual("||", parser.NextToken()); parser.MoveToNextLine(); Assert.AreEqual("text", parser.PeekNextToken()); }