Пример #1
0
        public void Sample2()
        {
            Pair   p  = new Pair();
            Thread t1 = new Thread(() =>
            {
                ChessAPI.ObserveOperationCall("set a=0");
                p.Write_a(0);
                ChessAPI.ObserveOperationReturn();
                ChessAPI.ObserveOperationCall("read both");
                ChessAPI.ObserveInteger("val", p.Read_both());
                ChessAPI.ObserveOperationReturn();
                ChessAPI.ObserveOperationCall("read a");
                ChessAPI.ObserveInteger("val", p.Read_a());
                ChessAPI.ObserveOperationReturn();
            });
            Thread t2 = new Thread(() =>
            {
                ChessAPI.ObserveOperationCall("set b=10");
                p.Write_b(10);
                ChessAPI.ObserveOperationReturn();
                ChessAPI.ObserveOperationCall("read both");
                ChessAPI.ObserveInteger("val", p.Read_both());
                ChessAPI.ObserveOperationReturn();
            });

            t1.Start();
            t2.Start();
            t1.Join();
            t2.Join();
        }
Пример #2
0
 public void SmallFailingSample1()
 {
     a = 0;
     b = 0;
     System.Threading.Tasks.Parallel.Invoke(
         () =>
     {
         ChessAPI.ObserveOperationCall("first");
         a = 1;
         ChessAPI.ObserveInteger("val", a);
         ChessAPI.ObserveOperationReturn();
     },
         () =>
     {
         ChessAPI.ObserveOperationCall("second");
         a = 2;
         ChessAPI.ObserveOperationReturn();
     }
         );
 }
Пример #3
0
        // harness for testing "Pair" objects
        private ComponentHarness <Pair> CreateHarness()
        {
            var harness = new ComponentHarness <Pair>();

            harness.DefineConstructor("default", () =>
            {
                return(new Pair());
            });
            harness.DefineOperation("read a", (Pair p) =>
            {
                int val = p.Read_a();
                ChessAPI.ObserveInteger("val", val);
            });
            harness.DefineOperation("read both", (Pair p) =>
            {
                int val = p.Read_both();
                ChessAPI.ObserveInteger("val", val);
            });
            for (int i = 0; i < 2; i++)
            {
                int val = i * 10;
                harness.DefineOperation("set a=" + val, (Pair p) =>
                {
                    p.Write_a(val);
                });
                harness.DefineOperation("set b=" + val, (Pair p) =>
                {
                    p.Write_b(val);
                });
            }
            harness.DefineOperation("set a=b=10", (Pair p) =>
            {
                p.Write_both(10, 10);
            });

            return(harness);
        }
Пример #4
0
 public void SmallPassingSample1()
 {
     a = 0;
     b = 0;
     System.Threading.Tasks.Parallel.Invoke(
         () =>
     {
         ChessAPI.ObserveOperationCall("first");
         a = 1;
         a = 1;
         b = a;
         ChessAPI.ObserveInteger("val", 2);
         ChessAPI.ObserveOperationReturn();
     },
         () =>
     {
         ChessAPI.ObserveOperationCall("second");
         b = 1;
         ChessAPI.ObserveString("ret", "hurra");
         b = 1;
         ChessAPI.ObserveOperationReturn();
     }
         );
 }