public void SemanticValidatorReturnsNoErrorsOnValidInput() { var text = "@NODE:FOR[MyMod] {}"; var tokens = ParseAndGetElements(text); var ast = new Builder(text, tokens).ast; var validator = new GeneralSemanticValidator(); Assert.False(validator.Validate("Test", ast).Any()); }
public void FirstAndAfterDeclarationsReturnsOneError() { var text = "@NODE:FIRST:AFTER[Mod] {}"; var tokens = ParseAndGetElements(text); var ast = new Builder(text, tokens).ast; var validator = new GeneralSemanticValidator(); var errors = validator.Validate("test", ast).ToList(); Assert.Equal("CN001", errors[0].WarningCode); Assert.Equal(1, errors.Count); }
public void MultipleForDeclarationsReturnsOneError() { var text = "@NODE:FOR[MyMod]:FOR[MyOtherMod] {}"; var tokens = ParseAndGetElements(text); var ast = new Builder(text, tokens).ast; var validator = new GeneralSemanticValidator(); var errors = validator.Validate("test", ast).ToList(); Assert.Equal("CN002", errors[0].WarningCode); Assert.Equal(1, errors.Count); }
public override bool Execute() { var parser = new NodeParser(); var validator = new GeneralSemanticValidator(); foreach (var file in Files) { var nodes = File.ReadAllText(file.ItemSpec); IList <LexicalElement> tokens; parser.Parse(nodes, file.ItemSpec, out tokens); foreach (var token in tokens.Where(token => token.Name.Contains("_"))) { LogError(new Warning(file.ItemSpec, token.StartCursor, token.EndCursor, "Syntax", token.Name)); } var ast = new Builder(nodes, tokens).ast; var warnings = validator.Validate(file.ItemSpec, ast); foreach (var warning in warnings) { LogWarning(warning); } } return(Log.HasLoggedErrors && !ContinueOnError); }