本文整理汇总了C#中System.Machine.LoadModule方法的典型用法代码示例。如果您正苦于以下问题:C# Machine.LoadModule方法的具体用法?C# Machine.LoadModule怎么用?C# Machine.LoadModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Machine
的用法示例。
在下文中一共展示了Machine.LoadModule方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAndUseFiboModule
public void LoadAndUseFiboModule()
{
Machine machine = new Machine();
var module = machine.LoadModule("fibo");
Assert.IsNotNull(module);
Assert.IsNotNull(module.Context);
Assert.AreEqual("fibo", module.Name);
Assert.IsNotNull(module.Context.GetValue("fibo/1"));
Assert.IsInstanceOfType(module.Context.GetValue("fibo/1"), typeof(MultiFunction));
var ffunc = (MultiFunction)module.Context.GetValue("fibo/1");
Assert.AreEqual(1, ffunc.Apply(null, new object[] { 0 }));
Assert.AreEqual(1, ffunc.Apply(null, new object[] { 1 }));
Assert.AreEqual(2, ffunc.Apply(null, new object[] { 2 }));
Assert.AreEqual(3, ffunc.Apply(null, new object[] { 3 }));
Assert.AreEqual(5, ffunc.Apply(null, new object[] { 4 }));
}
示例2: LoadAndUseTailModuleWithTailRecursion
public void LoadAndUseTailModuleWithTailRecursion()
{
Machine machine = new Machine();
var module = machine.LoadModule("tail");
Assert.IsNotNull(module);
Assert.IsNotNull(module.Context);
Assert.AreEqual("tail", module.Name);
Assert.IsNotNull(module.Context.GetValue("tail/2"));
Assert.IsInstanceOfType(module.Context.GetValue("tail/2"), typeof(MultiFunction));
var ffunc = (MultiFunction)module.Context.GetValue("tail/2");
var result = ffunc.Apply(null, new object[] { 2, 1 });
Assert.IsNotNull(result);
Assert.IsInstanceOfType(result, typeof(DelayedCall));
Assert.AreEqual(3, Machine.ExpandDelayedCall(result));
}
示例3: LoadAreaServer
public void LoadAreaServer()
{
Machine machine = new Machine();
var module = machine.LoadModule("area_server");
Assert.IsNotNull(module);
Assert.IsNotNull(module.Context);
Assert.AreEqual("area_server", module.Name);
Assert.IsNotNull(module.Context.GetValue("loop/0"));
machine.RootContext.SetValue(module.Name, module);
this.EvaluateExpression("Pid = spawn(fun() -> area_server:loop() end).", machine.RootContext);
Process process = new Process();
Process.Current = process;
this.EvaluateExpression("Pid ! {self(), rectangle, 6, 10}.", machine.RootContext);
Assert.AreEqual(60, process.GetMessage());
this.EvaluateExpression("Pid ! {self(), circle, 23}.", machine.RootContext);
Assert.AreEqual(3.14159 * 23 * 23, process.GetMessage());
this.EvaluateExpression("Pid ! stop.", machine.RootContext);
}
示例4: LoadArithModule
public void LoadArithModule()
{
Machine machine = new Machine();
var module = machine.LoadModule("arith");
Assert.IsNotNull(module);
Assert.IsNotNull(module.Context);
Assert.AreEqual("arith", module.Name);
Assert.IsNotNull(module.Context.GetValue("add/2"));
Assert.IsInstanceOfType(module.Context.GetValue("add/2"), typeof(Function));
Assert.IsNotNull(module.Context.GetValue("subtract/2"));
Assert.IsInstanceOfType(module.Context.GetValue("subtract/2"), typeof(Function));
Assert.IsNotNull(module.Context.GetValue("multiply/2"));
Assert.IsInstanceOfType(module.Context.GetValue("multiply/2"), typeof(Function));
Assert.IsNotNull(module.Context.GetValue("divide/2"));
Assert.IsInstanceOfType(module.Context.GetValue("divide/2"), typeof(Function));
}