using UnitTestSharp; namespace Ariadne.Generator.UnitTests { public class ScriptLocalsTests : TestFixture { public class FindTests : TestFixture { public void CallerOfAPassageWithLocals_ListsThemFromTheTop() { GeneratorRun run = GeneratorRun.Of(@" public partial class Delegating : Arc { private void Count(World world, int count) { wait: while (count > 0) { count--; Yield(); } } protected override void Run(World world) { Count(world, 3); } }"); CheckEqual(0, run.Compiled.Count); CheckTrue(run.CodeBehind.Contains("Run__LocalsToSave((__Frame)__CurrentFrame, 0, writer);")); CheckTrue(run.CodeBehind.Contains("Count__LocalsToSave(__frame, depth + 1, writer);")); } public void ScriptWithoutLocalsToSave_ListsNone() { GeneratorRun run = GeneratorRun.Of(@" public partial class Stateless : Arc { protected override void Run(World world) { wait: while (!world.Open.Contains(""wait"")) { Yield(); } } }"); CheckEqual(0, run.Compiled.Count); CheckFalse(run.CodeBehind.Contains("LocalsToSave")); } } } }