Skip to content

Commit

Permalink
unit test and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Dec 18, 2024
1 parent 6afd9e4 commit 3ec044a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/sly/lexer/GenericLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ protected readonly

private readonly IEqualityComparer<string> _keyWordComparer;

public GenericLexer(IdentifierType idType = IdentifierType.Alpha,
Action<IN, LexemeAttribute, GenericLexer<IN>> extensionBuilder = null,
params GenericToken[] staticTokens)
: this(new Config { IdType = idType, ExtensionBuilder = extensionBuilder }, staticTokens)
{
}

public GenericLexer(Config lexerConfig, GenericToken[] staticTokens)
{
LexerConfig = lexerConfig;
Expand All @@ -143,6 +136,8 @@ public void AddCallBack(IN token, Func<Token<IN>, Token<IN>> callback)
CallBacks[token] = callback;
}


[ExcludeFromCodeCoverage]
public void AddDefinition(TokenDefinition<IN> tokenDefinition)
{
}
Expand Down Expand Up @@ -1271,11 +1266,13 @@ public string ToGraphViz()
return TempLexerFsm.ToGraphViz();
}

[ExcludeFromCodeCoverage]
public IList<string> GetSubLexers()
{
return SubLexersFsm.Keys.ToList();
}

[ExcludeFromCodeCoverage]
public string ToGraphViz(string subLexerName)
{
if (SubLexersFsm.TryGetValue(subLexerName, out var subLexer))
Expand Down
10 changes: 10 additions & 0 deletions tests/ParserTests/samples/JsonGenericTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,15 @@ public void TestTrueBooleanValue()
Check.That(val.IsBool).IsTrue();
Check.That(val.GetValue<bool>()).IsTrue();
}

[Fact]
public void TestIncompleteObject()
{
var r = Parser.Parse("{\"prop\":\"value\",\"prop2\":[1,2,3");
Check.That(r).Not.IsOkParsing();
Check.That(r.Errors).CountIs(1);
var error = r.Errors[0];
Check.That(error.ErrorType).IsEqualTo(ErrorType.UnexpectedEOS);
}
}
}

0 comments on commit 3ec044a

Please sign in to comment.