void RunTest(string code, string expectedOutput) { ExpressionFinder p = new ExpressionFinder(); VBLexer lexer = new VBLexer(new StringReader(code)); Token t; do { t = lexer.NextToken(); p.InformToken(t); } while (t.Kind != Tokens.EOF); Console.WriteLine(p.Output); Assert.IsEmpty(p.Errors); Assert.AreEqual(expectedOutput.Replace("\r", ""), p.Output.Replace("\r", "")); }
void CheckTokens(VBLexer lexer, params int[] tokens) { for (int i = 0; i < tokens.Length; i++) { int token = tokens[i]; Token t = lexer.NextToken(); int next = t.Kind; Assert.IsEmpty(lexer.Errors.ErrorOutput); Assert.AreEqual(token, next, "{2} of {3}: expected: \"{0}\", was: \"{1}\"; at {4}", Tokens.GetTokenString(token), Tokens.GetTokenString(next), i + 1, tokens.Length, t.Location); } }
void CheckTokens(VBLexer lexer, params int[] tokens) { for (int i = 0; i < tokens.Length; i++) { int token = tokens[i]; Token t = lexer.NextToken(); int next = t.Kind; Assert.AreEqual(token, next, "{2} of {3}: {0} != {1}; at {4}", Tokens.GetTokenString(token), Tokens.GetTokenString(next), i + 1, tokens.Length, t.Location); } }