Пример #1
0
    def test_1(self):
        # create a client
        def client1(cl):
            cl.add(1)

        # create another client
        def client2(cl):
            cl.add(2)

        class Scenario_1(Scenario):
            def testcase(self):
                cl = concurrent_list()
                t1 = self.thread("client1", client1, cl)
                t2 = self.thread("client2", client2, cl)

                self.until_star().transfer_star()
                self.until_star().transfer_star()

                print("Cl:", cl)
                Assume(cl.contents() == [2, 1])
                Assert(1 in cl)
                Assert(2 in cl)

        scenario = Scenario_1().explore_exists()
        scenario.save("scenario_listtest3_test1")

        print("\nPrinting the scenario")
        print(str(scenario))

        scenario.save("scenario1.txt")

        print("\nLoaded scenario")
        print(Scenario.load("scenario1.txt"))
Пример #2
0
    def test_1(self):
        # create a client
        def client1(cl):
            cl.add(1)

        # create another client
        def client2(cl):
            cl.add(2)
        
        class Scenario_1(Scenario):
            
            def testcase(self):
                cl = concurrent_list()
                t1 = self.thread("client1", client1, cl)
                t2 = self.thread("client2", client2, cl)
                
                self.until_star().transfer_star()
                self.until_star().transfer_star()

                print("Cl:", cl)
                Assume(cl.contents() == [2, 1])
                Assert(1 in cl)
                Assert(2 in cl)

                
        scenario = Scenario_1().explore_exists()
        scenario.save("scenario_listtest3_test1")
        
        print("\nPrinting the scenario")
        print(str(scenario))

        scenario.save("scenario1.txt")

        print("\nLoaded scenario")
        print(Scenario.load("scenario1.txt"))
Пример #3
0
    def test_1(self):
        # create a list
        cl = None

        # create a client
        class client1(list_client):
            def run(self):
                cl.add(1)

        # create another client
        class client2(list_client):
            def run(self):
                cl.add(2)

        c1 = client1(1)
        c2 = client2(2)

        def create_list():
            nonlocal cl
            cl = concurrent_list()

        def final_checks():
            Assume(cl.contents() == [2, 1])
            Assert(1 in cl)
            Assert(2 in cl)

        scenario = explore([create_list], [c1, c2], [final_checks], scenario=None)
        
        print("\nPrinting the scenario")
        print(str(scenario))

        scenario.save("scenario1.txt")

        print("\nLoaded scenario")
        print(Scenario.load("scenario1.txt"))
Пример #4
0
    def test_1(self):
        # create a list
        cl = None

        # create a client
        class client1(list_client):
            def run(self):
                cl.add(1)

        # create another client
        class client2(list_client):
            def run(self):
                cl.add(2)

        c1 = client1(1)
        c2 = client2(2)

        def create_list():
            nonlocal cl
            cl = concurrent_list()

        def final_checks():
            Assume(cl.contents() == [2, 1])
            Assert(1 in cl)
            Assert(2 in cl)

        scenario = explore([create_list], [c1, c2], [final_checks],
                           scenario=None)

        print("\nPrinting the scenario")
        print(str(scenario))

        scenario.save("scenario1.txt")

        print("\nLoaded scenario")
        print(Scenario.load("scenario1.txt"))