@@ -727,8 +727,8 @@ def test_add_process_wrong(self):
727
727
def test_add_process_wrong_generator (self ):
728
728
with self .assertSimulation (Module ()) as sim :
729
729
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\) $" ):
732
732
def process ():
733
733
yield Delay ()
734
734
sim .add_process (process ())
@@ -743,12 +743,39 @@ def test_add_testbench_wrong(self):
743
743
def test_add_testbench_wrong_generator (self ):
744
744
with self .assertSimulation (Module ()) as sim :
745
745
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\) $" ):
748
748
def testbench ():
749
749
yield Delay ()
750
750
sim .add_testbench (testbench ())
751
751
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
+
752
779
def test_add_clock_wrong_twice (self ):
753
780
m = Module ()
754
781
s = Signal ()
@@ -2026,15 +2053,6 @@ async def testbench(ctx):
2026
2053
self .assertTrue (reached_tb )
2027
2054
self .assertTrue (reached_proc )
2028
2055
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
-
2038
2056
def test_issue_1368 (self ):
2039
2057
sim = Simulator (Module ())
2040
2058
async def testbench (ctx ):
0 commit comments