AjTalk.Tests.Language.BaseClassTest.DuplicateClassInOtherMachine C# (CSharp) Method

DuplicateClassInOtherMachine() private method

private DuplicateClassInOtherMachine ( ) : void
return void
        public void DuplicateClassInOtherMachine()
        {
            Loader loader = new Loader(@"DefineRectangleWithNewAndInitialize.st", new SimpleCompiler());
            Machine machine = new Machine();
            loader.LoadAndExecute(machine);

            BaseClass rectangle = (BaseClass)machine.GetGlobalObject("Rectangle");

            string output = rectangle.ToOutputString();

            Loader loader2 = new Loader(new StringReader(output), new VmCompiler());
            Machine machine2 = new Machine();
            loader2.LoadAndExecute(machine2);

            BaseClass rectangle2 = (BaseClass)machine2.GetGlobalObject("Rectangle");

            Assert.IsNotNull(rectangle2);
            Assert.IsNotNull(rectangle2.GetClassMethod("new"));
            Assert.IsNotNull(rectangle2.GetInstanceMethod("x"));
            Assert.IsNotNull(rectangle2.GetInstanceMethod("y"));
            Assert.IsNotNull(rectangle2.GetInstanceMethod("x:"));
            Assert.IsNotNull(rectangle2.GetInstanceMethod("y:"));
            Assert.IsNotNull(rectangle2.GetInstanceMethod("initialize"));

            Parser parser = new Parser("Rectangle new");
            Block block = parser.CompileBlock();
            object result = block.Execute(machine2, null);

            Assert.IsNotNull(result);

            Assert.IsInstanceOfType(result, typeof(IObject));

            IObject iobj = (IObject)result;

            Assert.AreEqual(10, iobj[0]);
            Assert.AreEqual(20, iobj[1]);
        }