@@ -716,8 +716,8 @@ def test_add_process_wrong(self):
716
716
def test_add_process_wrong_generator (self ):
717
717
with self .assertSimulation (Module ()) as sim :
718
718
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\) $" ):
721
721
def process ():
722
722
yield Delay ()
723
723
sim .add_process (process ())
@@ -732,12 +732,39 @@ def test_add_testbench_wrong(self):
732
732
def test_add_testbench_wrong_generator (self ):
733
733
with self .assertSimulation (Module ()) as sim :
734
734
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\) $" ):
737
737
def testbench ():
738
738
yield Delay ()
739
739
sim .add_testbench (testbench ())
740
740
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
+
741
768
def test_add_clock_wrong_twice (self ):
742
769
m = Module ()
743
770
s = Signal ()
@@ -2015,15 +2042,6 @@ async def testbench(ctx):
2015
2042
self .assertTrue (reached_tb )
2016
2043
self .assertTrue (reached_proc )
2017
2044
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
-
2027
2045
def test_issue_1368 (self ):
2028
2046
sim = Simulator (Module ())
2029
2047
async def testbench (ctx ):
0 commit comments