Better error message for script failure

This commit is contained in:
Tim Van Baak 2024-08-18 13:32:36 -07:00
parent f9f8ea2b5a
commit ea366220eb
1 changed files with 4 additions and 1 deletions

View File

@ -19,10 +19,13 @@ public class ScriptTests
[TestCaseSource(nameof(DatcTestCases))]
public void Test_DATC(string testScriptPath)
{
string filename = Path.GetFileName(testScriptPath);
int line = 0;
IScriptHandler? handler = new SetupScriptHandler(World.WithStandardMap(), strict: true);
foreach (string input in File.ReadAllLines(testScriptPath)) {
line++;
handler = handler?.HandleInput(input);
Assert.That(handler, Is.Not.Null, $"Script quit unexpectedly at \"{input}\"");
if (handler is null) Assert.Fail($"Script {filename} quit unexpectedly at line {line}: \"{input}\"");
}
}
}