private static async Task <SmallBasicEngine> VerifyRuntimeAux(this SmallBasicCompilation compilation, IEngineLibraries libraries, string memoryContents) { compilation.VerifyDiagnostics(); SmallBasicEngine engine = new SmallBasicEngine(compilation, libraries); while (engine.State != ExecutionState.Terminated) { engine.State.Should().Be(ExecutionState.Running, "loggers cannot move to another state"); await engine.Execute().ConfigureAwait(false); } DebuggerSnapshot snapshot = engine.GetSnapshot(); snapshot.ExecutionStack.Should().BeEmpty(); if (!memoryContents.IsDefault()) { string values = Environment.NewLine + snapshot.Memory.Select(pair => $"{pair.Key} = {pair.Value.ToDisplayString()}").Join(Environment.NewLine); values.Should().Be(memoryContents); } return(engine); }
public static async Task <SmallBasicEngine> VerifyExecutionState(this SmallBasicCompilation compilation, ExecutionState executionState, ExecutionMode mode = ExecutionMode.RunToEnd) { compilation.VerifyDiagnostics(); SmallBasicEngine engine = new SmallBasicEngine(compilation, new LibrariesCollection()); engine.Mode = mode; await engine.Execute().ConfigureAwait(false); engine.State.Should().Be(executionState); return(engine); }