@@ -716,8 +716,8 @@ def test_add_process_wrong(self):
716716 def test_add_process_wrong_generator (self ):
717717 with self .assertSimulation (Module ()) as sim :
718718 with self .assertRaisesRegex (TypeError ,
719- r"^Cannot add a process <.+?> because it is not an async function or "
720- r"generator function$" ):
719+ r"^Cannot add a process <.+?> because it is a generator object instead of "
720+ r"a function \(pass the function itself instead of calling it\) $" ):
721721 def process ():
722722 yield Delay ()
723723 sim .add_process (process ())
@@ -732,12 +732,39 @@ def test_add_testbench_wrong(self):
732732 def test_add_testbench_wrong_generator (self ):
733733 with self .assertSimulation (Module ()) as sim :
734734 with self .assertRaisesRegex (TypeError ,
735- r"^Cannot add a testbench <.+?> because it is not an async function or "
736- r"generator function$" ):
735+ r"^Cannot add a testbench <.+?> because it is a generator object instead of "
736+ r"a function \(pass the function itself instead of calling it\) $" ):
737737 def testbench ():
738738 yield Delay ()
739739 sim .add_testbench (testbench ())
740740
741+ def test_add_testbench_wrong_coroutine (self ):
742+ with self .assertSimulation (Module ()) as sim :
743+ with self .assertRaisesRegex (TypeError ,
744+ r"^Cannot add a testbench <.+?> because it is a coroutine object instead of "
745+ r"a function \(pass the function itself instead of calling it\)$" ):
746+ async def testbench ():
747+ pass
748+ sim .add_testbench (testbench ())
749+
750+ def test_add_testbench_wrong_async_generator (self ):
751+ with self .assertSimulation (Module ()) as sim :
752+ with self .assertRaisesRegex (TypeError ,
753+ r"^Cannot add a testbench <.+?> because it is a generator object instead of "
754+ r"a function \(pass the function itself instead of calling it\)$" ):
755+ async def testbench ():
756+ yield Delay ()
757+ sim .add_testbench (testbench ())
758+
759+ def test_add_testbench_wrong_async_generator_func (self ):
760+ with self .assertSimulation (Module ()) as sim :
761+ with self .assertRaisesRegex (TypeError ,
762+ r"^Cannot add a testbench <.+?> because it is an async generator function "
763+ r"\(there is likely a stray `yield` in the function\)$" ):
764+ async def testbench ():
765+ yield Delay ()
766+ sim .add_testbench (testbench )
767+
741768 def test_add_clock_wrong_twice (self ):
742769 m = Module ()
743770 s = Signal ()
@@ -2015,15 +2042,6 @@ async def testbench(ctx):
20152042 self .assertTrue (reached_tb )
20162043 self .assertTrue (reached_proc )
20172044
2018- def test_bug_1363 (self ):
2019- sim = Simulator (Module ())
2020- with self .assertRaisesRegex (TypeError ,
2021- r"^Cannot add a testbench <.+?> because it is not an async function or "
2022- r"generator function$" ):
2023- async def testbench ():
2024- yield Delay ()
2025- sim .add_testbench (testbench ())
2026-
20272045 def test_issue_1368 (self ):
20282046 sim = Simulator (Module ())
20292047 async def testbench (ctx ):
0 commit comments