public Task CallSubrutineAsync(string name) { if (subrutineTask != null) { Assert.Fail("Cannot run more subrutines in parallel."); } subrutineTask = Task.Run(() => runtime.CallSubrutine(name)); return(subrutineTask); }
public Task CallSubrutineAsync(string name) { if (subrutineTask != null) { Assert.Fail("Cannot run more subrutines in parallel."); } ScriptCancellation = new CancellationTokenSource(); subrutineTask = Task.Run(() => runtime.CallSubrutine(name)); return(subrutineTask); }
public static InjectionValue Execute(string subName, string codeBlock) { var runtime = new InjectionRuntime(); var parser = new Parser(); runtime.Load(parser.ParseFile(codeBlock, new FailTestErrorListener())); return(runtime.CallSubrutine(subName)); }
public static Task <InjectionValue> RunSubrutine(string subrutineName, Func <CancellationToken?> retrieveCancellationToken, string file) { return(Task.Run(() => { var runtime = new InjectionRuntime(retrieveCancellationToken); var parser = new Parser(); runtime.Load(parser.ParseFile(file, new FailTestErrorListener())); return runtime.CallSubrutine(subrutineName); })); }
public static void TestSubrutine(int expected, string subrutineName, string file) { var runtime = new InjectionRuntime(); var parser = new Parser(); runtime.Load(parser.ParseFile(file, new FailTestErrorListener())); var actual = runtime.CallSubrutine(subrutineName); Assert.AreEqual(InjectionValueKind.Integer, actual.Kind, file); Assert.AreEqual(expected, actual.Integer, file); }
public static void TestSubrutine(string expected, string codeBlock, NativeSubrutineDefinition[] natives = null) { var subrutine = $"sub test()\r\n{codeBlock}\r\n end sub"; var runtime = new InjectionRuntime(); if (natives != null) { runtime.Metadata.Add(natives); } var parser = new Parser(); runtime.Load(parser.ParseFile(subrutine, new FailTestErrorListener())); var actual = runtime.CallSubrutine("test"); Assert.AreEqual(InjectionValueKind.String, actual.Kind, codeBlock); Assert.AreEqual(expected, actual.String, codeBlock); }
public static void TestSubrutine(string codeBlock, NativeSubrutineDefinition[] natives = null, NativeSubrutineDefinition[] intrinsicVariables = null) { var subrutine = $"sub test()\r\n{codeBlock}\r\n end sub"; var runtime = new InjectionRuntime(); if (natives != null) { runtime.Metadata.Add(natives); } if (intrinsicVariables != null) { runtime.Metadata.AddIntrinsicVariables(intrinsicVariables); } var parser = new Parser(); runtime.Load(parser.ParseFile(subrutine, new FailTestErrorListener())); runtime.CallSubrutine("test"); }