public void ErrorReported() { var listener = new SourceErrorListener(); var message = "message"; var span = new SourceSpan( new SourceLocation(1, 1, 1), new SourceLocation(2, 2, 2)); var errorCode = 10; var severity = Severity.FatalError; listener.ErrorReported(null, message, span, errorCode, severity); var list = new List <ScriptErrorInformation> { new ScriptErrorInformation { Column = span.Start.Column, Line = span.Start.Line, Message = message, Severity = SyntaxVerificationSeverity.Error, }, }; Assert.That(listener.Errors(), Is.EquivalentTo(list)); }
/// <summary> /// Verifies that the script has no syntax errors. /// </summary> /// <param name="scriptCode">The script code.</param> /// <returns> /// A collection containing information about any present syntax problems, /// given as a line number and a syntax error message. /// </returns> public IEnumerable <ScriptErrorInformation> VerifySyntax(string scriptCode) { CreateScriptScope(ScriptCancellationToken, new CancelScriptToken()); var source = m_Engine.CreateScriptSourceFromString(scriptCode, SourceCodeKind.Statements); var errors = new SourceErrorListener(); var command = source.Compile(errors); if (command == null) { // Indicate that the errors were terminal } return(errors.Errors()); }
public void ErrorReported() { var listener = new SourceErrorListener(); var message = "message"; var span = new SourceSpan( new SourceLocation(1, 1, 1), new SourceLocation(2, 2, 2)); var errorCode = 10; var severity = Severity.FatalError; listener.ErrorReported(null, message, span, errorCode, severity); var list = new List<ScriptErrorInformation> { new ScriptErrorInformation { Column = span.Start.Column, Line = span.Start.Line, Message = message, Severity = SyntaxVerificationSeverity.Error, }, }; Assert.That(listener.Errors(), Is.EquivalentTo(list)); }
/// <summary> /// Verifies that the script has no syntax errors. /// </summary> /// <param name="scriptCode">The script code.</param> /// <returns> /// A collection containing information about any present syntax problems, /// given as a line number and a syntax error message. /// </returns> public IEnumerable<ScriptErrorInformation> VerifySyntax(string scriptCode) { CreateScriptScope(ScriptCancellationToken, new CancelScriptToken()); var source = m_Engine.CreateScriptSourceFromString(scriptCode, SourceCodeKind.Statements); var errors = new SourceErrorListener(); var command = source.Compile(errors); if (command == null) { // Indicate that the errors were terminal } return errors.Errors(); }