Esempio n. 1
0
 def test_select_raises_for_list_and_args(self):
     chan1 = goless.chan(1)
     chan2 = goless.chan(1)
     chan3 = goless.chan(1)
     cases = [goless.scase(chan1, 1), goless.scase(chan2, 2)]
     
     with self.assertRaises(TypeError):
         goless.select(cases, chan3)
Esempio n. 2
0
    def test_select_raises_for_list_and_args(self):
        chan1 = goless.chan(1)
        chan2 = goless.chan(1)
        chan3 = goless.chan(1)
        cases = [goless.scase(chan1, 1), goless.scase(chan2, 2)]

        with self.assertRaises(TypeError):
            goless.select(cases, chan3)
Esempio n. 3
0
 def test_case_switch(self):
     chan = goless.chan()
     cases = [goless.rcase(chan), goless.scase(chan, 1), goless.dcase()]
     chosen, value = goless.select(cases)
     if chosen is cases[0]:
         print('Received %s' % value)
     elif chosen is cases[1]:
         assert value is None
         print('Sent.')
     else:
         assert chosen is cases[2], chosen
         print('Default...')
Esempio n. 4
0
 def test_case_switch(self):
     chan = goless.chan()
     cases = [goless.rcase(chan), goless.scase(chan, 1), goless.dcase()]
     chosen, value = goless.select(cases)
     if chosen is cases[0]:
         print('Received %s' % value)
     elif chosen is cases[1]:
         assert value is None
         print('Sent.')
     else:
         assert chosen is cases[2], chosen
         print('Default...')
Esempio n. 5
0
 def setUp(self):
     BaseTests.setUp(self)
     self.ch = goless.chan(self.chansize)
     self.sendval = 1
     self.ca = goless.scase(self.ch, self.sendval)
Esempio n. 6
0
 def test_select_accepts_args(self):
     chan1 = goless.chan(1)
     scase = goless.scase(chan1, 1)
     chosen, val = goless.select(scase)
     self.assertIs(chosen, scase)
     self.assertIsNone(val)
Esempio n. 7
0
 def test_main_tasklet_can_select(self):
     chan1 = goless.chan(1)
     cases = [goless.scase(chan1, 3)]
     chosen, val = goless.select(cases)
     self.assertIs(chosen, cases[0])
     self.assertIsNone(val)
Esempio n. 8
0
 def test_main_tasklet_can_select(self):
     chan1 = goless.chan(1)
     cases = [goless.scase(chan1, 3)]
     chosen, val = goless.select(cases)
     self.assertIs(chosen, cases[0])
     self.assertIsNone(val)
Esempio n. 9
0
 def setUp(self):
     BaseTests.setUp(self)
     self.ch = goless.chan(self.chansize)
     self.sendval = 1
     self.ca = goless.scase(self.ch, self.sendval)
Esempio n. 10
0
 def test_select_accepts_args(self):
     chan1 = goless.chan(1)
     scase = goless.scase(chan1, 1)
     chosen, val = goless.select(scase)
     self.assertIs(chosen, scase)
     self.assertIsNone(val)