test(host): pin sequential clear-then-recompile contract of RoslynVirtualTagEvaluator (02/S12 baseline)
This commit is contained in:
+23
@@ -357,6 +357,29 @@ public sealed class RoslynVirtualTagEvaluatorTests
|
||||
CompiledCacheCount(sut).ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>02/S12 sequential pin: evaluating a compiled expression, clearing the cache, then
|
||||
/// evaluating the SAME source again succeeds both times and leaves the cache with exactly one entry
|
||||
/// (the recompile). This pins the clear-then-recompile contract the T8 retry-loop restructure must
|
||||
/// not regress.</summary>
|
||||
[Fact]
|
||||
public void Evaluate_after_ClearCompiledScripts_recompiles_and_succeeds()
|
||||
{
|
||||
using var sut = new RoslynVirtualTagEvaluator(NullLogger<RoslynVirtualTagEvaluator>.Instance, NoOpScriptRoot());
|
||||
const string expr = "return (int)ctx.GetTag(\"a\").Value + 1;";
|
||||
|
||||
var first = sut.Evaluate("vt-clear", expr, new Dictionary<string, object?> { ["a"] = 1 });
|
||||
first.Success.ShouldBeTrue(first.Reason);
|
||||
CompiledCacheCount(sut).ShouldBe(1);
|
||||
|
||||
sut.ClearCompiledScripts();
|
||||
CompiledCacheCount(sut).ShouldBe(0);
|
||||
|
||||
var second = sut.Evaluate("vt-clear", expr, new Dictionary<string, object?> { ["a"] = 41 });
|
||||
second.Success.ShouldBeTrue(second.Reason);
|
||||
second.Value.ShouldBe(42);
|
||||
CompiledCacheCount(sut).ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Reads the count of the private compiled-script cache via reflection. The cache is a
|
||||
/// <c>CompiledScriptCache<,></c> which exposes a <c>Count</c> property (not <c>ICollection</c>).</summary>
|
||||
private static int CompiledCacheCount(RoslynVirtualTagEvaluator sut)
|
||||
|
||||
Reference in New Issue
Block a user