public void EchoWithDispose() { var interpreterSettings = new Dictionary <string, string> { ["RUNASSERVICE"] = "2", ["MAXWS"] = "1G" }; for (int i = 0; i < 1000; i++) { var interpreter = new DyalogInterpreter(null, interpreterSettings) { SingleThreaded = true, DeleteOnUnload = true }; try { var apl = new AplGroup001.SubSpace.A1(interpreter); var result = apl.Echo(i); Assert.AreEqual(i, result); apl.Dispose(); } finally { interpreter.Unload(); } } }
static void Main(string[] args) { // long result; // Stopwatch stop; var interpreter = new DyalogInterpreter(); interpreter.SingleThreaded = true; interpreter.DeleteOnUnload = true; var calc = new Calculator(interpreter); // Test good old exit specification (xs) // calc.SetStopThis("Sum"); try { var resultUpper = calc.Upper("TestSystemErrors"); var result = calc.Sum(new int[0]); } catch (AplExitSpecificationException ex) { Console.WriteLine("Exception: " + ex.Message); } // Test Dyalog APL system error - DOMAIN ERROR try { var result2 = calc.Divide(4, 0); } catch (AplDomainErrorException ex) { Console.WriteLine("Exception: " + ex.Message); } var interpreter2 = new DyalogInterpreter(); interpreter2.SingleThreaded = true; using (var test = new ClassWithDispose(interpreter)) { // test.SetStopThis("Divide"); try { var result = test.Divide(4, 0); } catch (AplDomainErrorException ex) { Console.WriteLine("Exception: " + ex.Message); } } var test2 = new ClassWithDispose(interpreter2); // test.SetStopThis("MakeBigVar"); var newClass = test2.GetNewInstance(99); Console.WriteLine("[]WA: " + test2.WsAwail()); //test2.ExecuteExpr("#.BigVar←1000 1000⍴⊂'Trala'"); //var bigvar = test2.ExecuteExprWithResult("#.BigVar"); //test2.ExecuteExpr("⎕EX'#.BigVar'"); test2.MakeBigVar(1000, 1000, "Tralala"); interpreter.Unload(); (test2 as IDisposable)?.Dispose(); interpreter2.Unload(); Console.WriteLine("Press any key to stop..."); Console.ReadKey(); }
public void DivideByZeroTest() { var interpreter = new DyalogInterpreter(); interpreter.SingleThreaded = true; interpreter.DeleteOnUnload = true; try { var test = new Calculator(interpreter); var result = test.Divide(4, 0); } finally { interpreter.Unload(); } }
static void Main(string[] args) { Console.WriteLine("Press <ENTER> to begin"); Console.ReadLine(); for (int i = 0; i < 10; i++) { Console.WriteLine("============================< START OF {0:D4} >============================", i); var process = Process.GetCurrentProcess(); var ws = process.WorkingSet64; var pb = process.PrivateMemorySize64; if (i == 0) { Init_WS = ws; Init_PB = pb; } ReportResources(process, "Initial"); var interpreter = new DyalogInterpreter { SingleThreaded = true, DeleteOnUnload = true }; try { var apl = new SimpleAplClass(interpreter); int result = apl.CallWithArgument(15); Console.WriteLine("Result from APL: {0}", result); } finally { Console.WriteLine("Successfully unloaded interpreter: {0}", interpreter.Unload()); ReportResources(process, "After unload"); } Console.WriteLine(); //Console.ReadLine(); } Console.WriteLine("=================================< END >================================="); Console.WriteLine("Initial WS {0,15:N0} bytes", Init_WS); Console.WriteLine("Final WS {0,15:N0} bytes", Prev_WS); Console.WriteLine("Diff WS {0,15:N0} bytes", Prev_WS - Init_WS); Console.WriteLine(); Console.WriteLine("Initial PB {0,15:N0} bytes", Init_PB); Console.WriteLine("Final PB {0,15:N0} bytes", Prev_PB); Console.WriteLine("Diff PB {0,15:N0} bytes", Prev_PB - Init_PB); Console.WriteLine(); Console.WriteLine("Press <ENTER> to exit"); Console.ReadLine(); }
public void APLCoreTest() { var interpreter = new DyalogInterpreter(); interpreter.SingleThreaded = true; interpreter.DeleteOnUnload = true; var test = new TestSystemErrors(interpreter); try { test.TryCreateAPLCore(); } finally { interpreter.Unload(); } }
private void CreateAPLObjectCallWithArgAndUnload() { DyalogInterpreter interpreter = new DyalogInterpreter(); interpreter.SingleThreaded = true; interpreter.DeleteOnUnload = DeleteOnUnload; try { var apl = new SimpleAplClass(interpreter); int result = apl.CallWithArgument(15); Assert.AreEqual(15, result); } finally { Assert.IsTrue(interpreter.Unload()); } }
public void SetAndGetData() { var interpreter = new DyalogInterpreter(); interpreter.SingleThreaded = true; interpreter.DeleteOnUnload = true; try { using (var test = new ClassWithDispose(interpreter)) { test.MakeBigVar(1000, 1000, "Tralala"); var bigvar = test.GetBigVar(); var rank = ((object[, ])bigvar).Rank; Assert.AreEqual(2, rank); } } finally { interpreter.Unload(); } }
private void CreateAPLObjectCallWithLoopedOperationAndUnload(int innerLoopSize) { DyalogInterpreter interpreter = new DyalogInterpreter(); interpreter.SingleThreaded = true; interpreter.DeleteOnUnload = DeleteOnUnload; try { var apl = new SimpleAplClass(interpreter); int result = apl.Call(innerLoopSize); Assert.AreEqual(1, result); } /*catch (Exception e) { * * * } */finally { Assert.IsTrue(interpreter.Unload()); } }
public void WSFullTest() { Dictionary <string, string> confSettings = new Dictionary <string, string>(); confSettings.Add("maxws", "512K"); var interpreter = new DyalogInterpreter(null, confSettings); interpreter.SingleThreaded = true; interpreter.DeleteOnUnload = true; using (var test = new ClassWithDispose(interpreter)) { try { test.MakeBigVar(1000, 1000, "Tralala"); var bigvar = test.GetBigVar(); } finally { interpreter.Unload(); } } }
public void NestedInstanceSingleHost() { var interpreter = new DyalogInterpreter(".\\dyalog180_64_unicode.dll", null) { SingleThreaded = true, DeleteOnUnload = true }; try { var apl = new AplGroup003.NestedClassSimpleName(1, interpreter); Assert.AreEqual(1, apl.ID()); Assert.AreEqual(1, apl.ThisID()); apl.Init(); Assert.AreEqual(2, apl.ID()); Assert.AreEqual(2, apl.NestedID()); Assert.AreEqual(2, apl.ThisID()); } finally { interpreter.Unload(); } }