Ejemplo n.º 1
0
        public void Test18()
        {
            var code = @"
                st = new Stage
                    Procs
                        add sink = new Process
                        add p1 = new Process
                            Name = 'MyProc'
                            Cio
                                add o1 = new CoMaxCost
            ";
            var jac  = new JacInterpreter();

            jac.Exec(code);
            var st = jac.GetStage("st");

            Assert.AreEqual(jac.GetProcess("MyProc")?.Name, "MyProc");
            Assert.AreEqual(jac.GetProcess("MyProc")?.Cios.Count(), 1);

            var code2 = @"
                w1 = new Work
                    Next = l1 = new Location
                        Stage = st
                        SubsetCache = st
                        Path = '\'
                        Process = p1 = new Process
                w2 = new Work
                    Current = w1.Next
                w3 = new Work
                    Previous = w2.Current
                w4 = new Work
                    Current = l1
            ";

            jac.Exec(code2);
            var w1 = jac.GetWork("w1");
            var w2 = jac.GetWork("w2");
            var w3 = jac.GetWork("w3");
            var w4 = jac.GetWork("w4");
            var p1 = jac.GetProcess("p1");
            var l1 = jac.GetLocation("l1");

            Assert.IsNotNull(p1);
            Assert.IsNull(w1.Previous);
            Assert.IsNull(w1.Current);
            Assert.AreEqual(w1.Next.SubsetCache, st);
            Assert.AreEqual(w1.Next.Process, p1);
            Assert.AreEqual(w2.Current.SubsetCache, w1.Next.SubsetCache);
            Assert.AreEqual(w2.Current.SubsetCache, st);
            Assert.AreEqual(w2.Current.Process, p1);
            Assert.AreEqual(w3.Previous.SubsetCache, st);
            Assert.AreEqual(w3.Previous.Process, p1);
            Assert.AreEqual(w4.Current, l1);

            var code3 = @"
                o1
                    ReferenceVarName = 'Weight'
                    Value = 500
            ";

            jac.Exec(code3);

            var o1 = jac["o1"] as CoMaxCost;

            Assert.IsNotNull(o1);
            Assert.AreEqual(o1.ReferenceVarName, JitVariable.From("Weight"));
            Assert.AreEqual(o1.Value, 500.0);
        }