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();
 }
Exemple #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);
        }
Exemple #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");
        }
Exemple #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");
        }