From fd311e747c67faa4e61873dcfefd4159b67f977a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 20 Apr 2015 14:33:15 -0400 Subject: Add a test with bidirectional generators --- tests/test_arcs.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 2b7dafd4..a4462ea1 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -646,6 +646,27 @@ class YieldTest(CoverageTest): arcz_missing=".3 3-3", arcz_unpredicted="") + def test_coroutines(self): + self.check_coverage("""\ + def double_inputs(): + while [1]: # avoid compiler differences + x = yield + x *= 2 + yield x + + gen = double_inputs() + next(gen) + print(gen.send(10)) + next(gen) + print(gen.send(6)) + """, + arcz= + ".1 17 78 89 9A AB B. " + ".2 23 34 45 52 2.", + arcz_missing="2.", + arcz_unpredicted="") + self.assertEqual(self.stdout(), "20\n12\n") + class MiscArcTest(CoverageTest): """Miscellaneous arc-measuring tests.""" -- cgit v1.2.1