Implement assert has-past

This commit is contained in:
Tim Van Baak 2024-09-03 03:49:38 +00:00
parent 4fee854c4c
commit e9c9999268
2 changed files with 13 additions and 2 deletions

View File

@ -101,7 +101,19 @@ public class AdjudicationQueryScriptHandler(
return ScriptResult.Succeed(this);
case "has-past":
// Assert a timeline's past
Regex hasPast = new($"^([a-z]+[0-9]+)>([a-z]+[0-9]+)$");
Match hpMatch = hasPast.Match(args[1]);
if (!hpMatch.Success) return ScriptResult.Fail("Expected format s1>s2", this);
Season future = new(hpMatch.Groups[1].Value);
if (!World.Timelines.Pasts.TryGetValue(future.Key, out Season? actual)) {
return ScriptResult.Fail($"No such season \"{future}\"");
}
Season expected = new(hpMatch.Groups[2].Value);
if (actual != expected) return ScriptResult.Fail(
$"Expected past of {future} to be {expected}, but it was {actual}");
return ScriptResult.Succeed(this);
case "holds":
// Assert a unit successfully held

View File

@ -116,7 +116,6 @@ public class ReplTest
[Test]
public void AssertSeasonPast()
{
Assert.Ignore();
var repl = StandardRepl();
repl.ExecuteAll("""