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)
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...')
def setUp(self): BaseTests.setUp(self) self.ch = goless.chan(self.chansize) self.sendval = 1 self.ca = goless.scase(self.ch, self.sendval)
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)
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)