public void IgnoreComments() { var lexer = new StringLexer ("# this is a comment"); var token = lexer.GetToken (); Assert.AreEqual (TokenType.EOF, token.Type); }
public void IgnoreWhitespace(string input) { var lexer = new StringLexer (input); var token = lexer.GetToken (); Assert.AreEqual (TokenType.EOF, token.Type); }
public void ErrorOnUnfinishedSingleQuote() { var lexer = new StringLexer ("'foobar"); var ex = Assert.Throws<LexerException> (() => lexer.GetToken ()); Assert.That (NOT_CLOSED_RE.IsMatch (ex.Message)); }
public void LexFunctionCallDelimiters(string input, TokenType expected) { var lexer = new StringLexer (input); var token = lexer.GetToken (); Assert.AreEqual (expected, token.Type); }
public void ErrorOnInvalidInput() { var lexer = new StringLexer ("{foobar}"); var ex = Assert.Throws<LexerException> (() => lexer.GetToken ()); Assert.That (INVALID_RE.IsMatch (ex.Message)); }
public void LexNumbers(string input, double expected) { var lexer = new StringLexer (input); var token = lexer.GetToken (); Assert.AreEqual (TokenType.Number, token.Type); Assert.AreEqual (expected, token.GetNumberValue ()); token = lexer.GetToken (); Assert.AreEqual (TokenType.EOF, token.Type); }
public void ReturnEOF() { var lexer = new StringLexer (""); var token = lexer.GetToken (); Assert.AreEqual (TokenType.EOF, token.Type); token = lexer.GetToken (); Assert.AreEqual (TokenType.EOF, token.Type); token = lexer.GetToken (); Assert.AreEqual (TokenType.EOF, token.Type); }
public void LexStrings(string input, string expected) { var lexer = new StringLexer (input); var token = lexer.GetToken (); Assert.AreEqual (TokenType.String, token.Type); Assert.AreEqual (expected, token.GetStringValue ()); token = lexer.GetToken (); Assert.AreEqual (TokenType.EOF, token.Type); }
public void LexReferences(string input, string[] expected) { var lexer = new StringLexer (input); var token = lexer.GetToken (); Assert.AreEqual (TokenType.Reference, token.Type); var segments = token.GetReferenceValue (); Assert.AreEqual (expected.Length, segments.Length); for (var i = 0; i < expected.Length; i += 1) { Assert.AreEqual (expected [i], segments [i]); } }