Skip to content

Commit

Permalink
lexer extension unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Jun 4, 2019
1 parent fc2c4c3 commit 28275f5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ParserTests/lexer/GenericLexerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,27 @@ public void TestExtensions()
tok = tokens[0];
Assert.Equal(Extensions.CHAINE, tok.TokenID);
Assert.Equal("'et voilà'", tokens[0].Value);
}

[Fact]
public void TestExtensionsPreconditionFailure()
{
var lexerRes =
LexerBuilder.BuildLexer(new BuildResult<ILexer<Extensions>>(), ExtendedGenericLexer.AddExtension);
Assert.False(lexerRes.IsError);
var lexer = lexerRes.Result as GenericLexer<Extensions>;
Assert.NotNull(lexer);

var err = Assert.Throws<LexerException>(() => lexer.Tokenize("0.0.2018"));
var lexErr = err as LexerException;
Assert.Equal(0,lexErr.Error.Line);
Assert.Equal(3,lexErr.Error.Column);
Assert.Equal('.',lexErr.Error.UnexpectedChar);
;




}

[Fact]
Expand Down

0 comments on commit 28275f5

Please sign in to comment.