Improved diagnostic handling
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using PorygonSharp;
|
||||
using PorygonSharp.UserData;
|
||||
@@ -16,7 +17,7 @@ namespace PorygonSharpTests
|
||||
var diags = script.Diagnostics.GetDiagnostics();
|
||||
foreach (var diag in diags)
|
||||
{
|
||||
throw new Exception(diag.GetCode().ToString());
|
||||
throw new Exception(script.Diagnostics.GetFullDiagnosticMessage(diag));
|
||||
}
|
||||
Assert.False(script.Diagnostics.HasErrors());
|
||||
}
|
||||
@@ -109,6 +110,18 @@ namespace PorygonSharpTests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDiagnostic()
|
||||
{
|
||||
using (var script = new Script("\n'\\x'"))
|
||||
{
|
||||
var diagnostics = script.Diagnostics.GetDiagnostics().ToArray();
|
||||
Assert.IsNotEmpty(diagnostics);
|
||||
Assert.AreEqual("[Error] (1, 3) '\\x' is not a valid control character.", script.Diagnostics.GetFullDiagnosticMessage(diagnostics[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestHash()
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ end
|
||||
var diags = script.Diagnostics.GetDiagnostics();
|
||||
foreach (var diag in diags)
|
||||
{
|
||||
throw new Exception(diag.GetCode().ToString());
|
||||
throw new Exception(script.Diagnostics.GetFullDiagnosticMessage(diag));
|
||||
}
|
||||
|
||||
script.Evaluate();
|
||||
@@ -54,7 +54,7 @@ end
|
||||
var diags = script.Diagnostics.GetDiagnostics();
|
||||
foreach (var diag in diags)
|
||||
{
|
||||
throw new Exception(diag.GetCode().ToString());
|
||||
throw new Exception(script.Diagnostics.GetFullDiagnosticMessage(diag));
|
||||
}
|
||||
|
||||
script.Evaluate();
|
||||
@@ -78,7 +78,7 @@ end
|
||||
var diags = script.Diagnostics.GetDiagnostics();
|
||||
foreach (var diag in diags)
|
||||
{
|
||||
throw new Exception(diag.GetCode().ToString());
|
||||
throw new Exception(script.Diagnostics.GetFullDiagnosticMessage(diag));
|
||||
}
|
||||
|
||||
script.Evaluate();
|
||||
@@ -119,7 +119,7 @@ end
|
||||
var diags = script.Diagnostics.GetDiagnostics();
|
||||
foreach (var diag in diags)
|
||||
{
|
||||
throw new Exception(diag.GetCode().ToString());
|
||||
throw new Exception(script.Diagnostics.GetFullDiagnosticMessage(diag));
|
||||
}
|
||||
|
||||
script.Evaluate();
|
||||
|
||||
Reference in New Issue
Block a user