harden(vtag): exclude backslash from passthrough capture + parity tests (A review)
This commit is contained in:
+32
@@ -200,6 +200,38 @@ public sealed class RoslynVirtualTagEvaluatorTests
|
||||
result.Reason.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Direct parity test: the EXACT mirror source <c>return ctx.GetTag("missing").Value;</c>
|
||||
/// evaluated against an empty dependency dictionary takes the fast-path and yields
|
||||
/// <c>Ok(null)</c>; a minimally-altered but semantically-identical non-passthrough variant
|
||||
/// <c>return (object?)ctx.GetTag("missing").Value;</c> compiled by Roslyn against the same
|
||||
/// empty deps yields the identical <c>Ok(null)</c> — proving the fast-path is byte-identical
|
||||
/// to the Roslyn path for the missing-dependency case.</summary>
|
||||
[Fact]
|
||||
public void Passthrough_exact_mirror_missing_dep_matches_Roslyn_baseline()
|
||||
{
|
||||
using var sut = new RoslynVirtualTagEvaluator(NullLogger<RoslynVirtualTagEvaluator>.Instance);
|
||||
|
||||
// Fast-path: exact mirror shape → passthrough returns Ok(null) for missing dep.
|
||||
var fastPath = sut.Evaluate(
|
||||
"vt-parity-fast",
|
||||
"return ctx.GetTag(\"missing\").Value;",
|
||||
new Dictionary<string, object?>());
|
||||
|
||||
fastPath.Success.ShouldBeTrue(fastPath.Reason);
|
||||
fastPath.Value.ShouldBeNull();
|
||||
fastPath.Reason.ShouldBeNull();
|
||||
|
||||
// Roslyn path: `(object?)` cast forces compilation but reads the same missing tag.
|
||||
var roslynPath = sut.Evaluate(
|
||||
"vt-parity-roslyn",
|
||||
"return (object?)ctx.GetTag(\"missing\").Value;",
|
||||
new Dictionary<string, object?>());
|
||||
|
||||
roslynPath.Success.ShouldBeTrue(roslynPath.Reason);
|
||||
roslynPath.Value.ShouldBeNull();
|
||||
roslynPath.Reason.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Decisive proof the fast-path skips Roslyn: the compiled-script cache (which every
|
||||
/// Roslyn evaluation populates via <c>GetOrAdd</c>) stays EMPTY after a mirror evaluation, then
|
||||
/// grows to one entry once a genuine (non-mirror) expression forces compilation.</summary>
|
||||
|
||||
Reference in New Issue
Block a user