示例#1
0
 protected override object Evaluate(string text, Machine machine)
 {
     Parser parser = new Parser(text);
     Block block = parser.CompileBlock();
     Process process = new Process(block, null, machine);
     return process.Execute();
 }
示例#2
0
        public void NewProcess()
        {
            Machine machine = new Machine();
            Block block = new Block();

            Process process = new Process(block, null, machine);

            Assert.AreSame(machine, process.Machine);
            Assert.AreSame(block, process.Block);
            Assert.IsNull(process.Arguments);
        }
示例#3
0
        public void RunProcess()
        {
            AutoResetEvent handle = new AutoResetEvent(false);
            Machine machine = new Machine();
            machine.SetGlobalObject("handle", handle);
            Block block = (new VmCompiler()).CompileBlock("handle !Set");

            Process process = new Process(block, null, machine);

            process.Start();

            if (!handle.WaitOne(500))
                Assert.Fail("Process didn't run");
        }
示例#4
0
        public void ResumeNewProcess()
        {
            AutoResetEvent handle = new AutoResetEvent(false);
            Machine machine = new Machine();
            VmCompiler compiler = new VmCompiler();
            machine.SetGlobalObject("handle", handle);
            Block block = compiler.CompileBlock("handle !Set");

            Process process = new Process(block, null, machine);
            machine.SetGlobalObject("process", process);

            compiler.CompileBlock("process resume").Execute(machine, null);

            if (!handle.WaitOne(500))
                Assert.Fail("Process didn't run");
        }