@@ -727,8 +727,8 @@ def test_add_process_wrong(self):
727727 def test_add_process_wrong_generator (self ):
728728 with self .assertSimulation (Module ()) as sim :
729729 with self .assertRaisesRegex (TypeError ,
730- r"^Cannot add a process <.+?> because it is not an async function or "
731- r"generator function$" ):
730+ r"^Cannot add a process <.+?> because it is a generator object instead of "
731+ r"a function \(pass the function itself instead of calling it\) $" ):
732732 def process ():
733733 yield Delay ()
734734 sim .add_process (process ())
@@ -743,12 +743,39 @@ def test_add_testbench_wrong(self):
743743 def test_add_testbench_wrong_generator (self ):
744744 with self .assertSimulation (Module ()) as sim :
745745 with self .assertRaisesRegex (TypeError ,
746- r"^Cannot add a testbench <.+?> because it is not an async function or "
747- r"generator function$" ):
746+ r"^Cannot add a testbench <.+?> because it is a generator object instead of "
747+ r"a function \(pass the function itself instead of calling it\) $" ):
748748 def testbench ():
749749 yield Delay ()
750750 sim .add_testbench (testbench ())
751751
752+ def test_add_testbench_wrong_coroutine (self ):
753+ with self .assertSimulation (Module ()) as sim :
754+ with self .assertRaisesRegex (TypeError ,
755+ r"^Cannot add a testbench <.+?> because it is a coroutine object instead of "
756+ r"a function \(pass the function itself instead of calling it\)$" ):
757+ async def testbench ():
758+ pass
759+ sim .add_testbench (testbench ())
760+
761+ def test_add_testbench_wrong_async_generator (self ):
762+ with self .assertSimulation (Module ()) as sim :
763+ with self .assertRaisesRegex (TypeError ,
764+ r"^Cannot add a testbench <.+?> because it is a generator object instead of "
765+ r"a function \(pass the function itself instead of calling it\)$" ):
766+ async def testbench ():
767+ yield Delay ()
768+ sim .add_testbench (testbench ())
769+
770+ def test_add_testbench_wrong_async_generator_func (self ):
771+ with self .assertSimulation (Module ()) as sim :
772+ with self .assertRaisesRegex (TypeError ,
773+ r"^Cannot add a testbench <.+?> because it is an async generator function "
774+ r"\(there is likely a stray `yield` in the function\)$" ):
775+ async def testbench ():
776+ yield Delay ()
777+ sim .add_testbench (testbench )
778+
752779 def test_add_clock_wrong_twice (self ):
753780 m = Module ()
754781 s = Signal ()
@@ -2026,15 +2053,6 @@ async def testbench(ctx):
20262053 self .assertTrue (reached_tb )
20272054 self .assertTrue (reached_proc )
20282055
2029- def test_bug_1363 (self ):
2030- sim = Simulator (Module ())
2031- with self .assertRaisesRegex (TypeError ,
2032- r"^Cannot add a testbench <.+?> because it is not an async function or "
2033- r"generator function$" ):
2034- async def testbench ():
2035- yield Delay ()
2036- sim .add_testbench (testbench ())
2037-
20382056 def test_issue_1368 (self ):
20392057 sim = Simulator (Module ())
20402058 async def testbench (ctx ):
0 commit comments