private void NextStepButton_Click(object sender, RoutedEventArgs e) { _interpreter.NextStep(); }
public async Task BaZicInterpreterStepInto() { var parser = new BaZicParser(); var inputCode = @"EXTERN FUNCTION Main(args[]) VARIABLE var1 = 0 BREAKPOINT var1 = 1 var1 = 2 var1 = 3 RETURN var1 END FUNCTION"; var interpreter = new BaZicInterpreter(parser.Parse(inputCode, false).Program); var t = interpreter.StartDebugAsync(true); await Task.Delay(3000); var expectedLogs = @"[State] Ready [State] Preparing [Log] Reference assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Declaring global variables. [Log] Program's entry point detected. [State] Running [Log] Preparing to invoke the method 'Main'. [Log] Executing the argument values of the method. [Log] Executing an expression of type 'ArrayCreationExpression'. [Log] The expression returned the value 'BaZicProgramReleaseMode.ObservableDictionary' (BaZicProgramReleaseMode.ObservableDictionary (length: 0)). [Log] Invoking the synchronous method 'Main'. [Log] Variable 'args' declared. Default value : {Null} [Log] Variable 'args' value set to : BaZicProgramReleaseMode.ObservableDictionary (BaZicProgramReleaseMode.ObservableDictionary (length: 0)) [Log] Registering labels. [Log] Executing a statement of type 'VariableDeclaration'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '0' (System.Int32). [Log] Variable 'var1' declared. Default value : 0 (System.Int32) [Log] Executing a statement of type 'BreakpointStatement'. [Log] A Breakpoint has been intercepted. [State] Pause "; Assert.AreEqual(expectedLogs, interpreter.GetStateChangedHistoryString()); Assert.AreEqual(BaZicInterpreterState.Pause, interpreter.State); interpreter.NextStep(); await Task.Delay(1000); Assert.AreEqual(BaZicInterpreterState.Pause, interpreter.State); interpreter.NextStep(); await Task.Delay(1000); expectedLogs = @"[State] Ready [State] Preparing [Log] Reference assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Declaring global variables. [Log] Program's entry point detected. [State] Running [Log] Preparing to invoke the method 'Main'. [Log] Executing the argument values of the method. [Log] Executing an expression of type 'ArrayCreationExpression'. [Log] The expression returned the value 'BaZicProgramReleaseMode.ObservableDictionary' (BaZicProgramReleaseMode.ObservableDictionary (length: 0)). [Log] Invoking the synchronous method 'Main'. [Log] Variable 'args' declared. Default value : {Null} [Log] Variable 'args' value set to : BaZicProgramReleaseMode.ObservableDictionary (BaZicProgramReleaseMode.ObservableDictionary (length: 0)) [Log] Registering labels. [Log] Executing a statement of type 'VariableDeclaration'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '0' (System.Int32). [Log] Variable 'var1' declared. Default value : 0 (System.Int32) [Log] Executing a statement of type 'BreakpointStatement'. [Log] A Breakpoint has been intercepted. [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''1' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '1' (System.Int32). [Log] Variable 'var1' value set to : 1 (System.Int32) [Log] 'var1' is now equal to '1'(type:System.Int32) [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''2' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '2' (System.Int32). [Log] Variable 'var1' value set to : 2 (System.Int32) [Log] 'var1' is now equal to '2'(type:System.Int32) [State] Pause "; Assert.AreEqual(expectedLogs, interpreter.GetStateChangedHistoryString()); Assert.AreEqual(BaZicInterpreterState.Pause, interpreter.State); await interpreter.Stop(); await Task.Delay(1000); expectedLogs = @"[State] Ready [State] Preparing [Log] Reference assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' loaded in the application domain. [Log] Reference assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' loaded in the application domain. [Log] Reference assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Reference assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' loaded in the application domain. [Log] Declaring global variables. [Log] Program's entry point detected. [State] Running [Log] Preparing to invoke the method 'Main'. [Log] Executing the argument values of the method. [Log] Executing an expression of type 'ArrayCreationExpression'. [Log] The expression returned the value 'BaZicProgramReleaseMode.ObservableDictionary' (BaZicProgramReleaseMode.ObservableDictionary (length: 0)). [Log] Invoking the synchronous method 'Main'. [Log] Variable 'args' declared. Default value : {Null} [Log] Variable 'args' value set to : BaZicProgramReleaseMode.ObservableDictionary (BaZicProgramReleaseMode.ObservableDictionary (length: 0)) [Log] Registering labels. [Log] Executing a statement of type 'VariableDeclaration'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '0' (System.Int32). [Log] Variable 'var1' declared. Default value : 0 (System.Int32) [Log] Executing a statement of type 'BreakpointStatement'. [Log] A Breakpoint has been intercepted. [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''1' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '1' (System.Int32). [Log] Variable 'var1' value set to : 1 (System.Int32) [Log] 'var1' is now equal to '1'(type:System.Int32) [State] Pause [State] Running [Log] Executing a statement of type 'AssignStatement'. [Log] Assign 'var1' to ''2' (type:System.Int32)'. [Log] Executing an expression of type 'PrimitiveExpression'. [Log] The expression returned the value '2' (System.Int32). [Log] Variable 'var1' value set to : 2 (System.Int32) [Log] 'var1' is now equal to '2'(type:System.Int32) [State] Pause [Log] The user requests to stop the interpreter as soon as possible. [State] Stopped "; Assert.AreEqual(expectedLogs, interpreter.GetStateChangedHistoryString()); Assert.AreEqual(BaZicInterpreterState.Stopped, interpreter.State); }