amaranth/tests/compat/test_passive.py

24 lines
477 B
Python
Raw Normal View History

import unittest
2021-12-09 22:39:50 -07:00
from amaranth.compat import *
class PassiveCase(unittest.TestCase):
def test_terminates_correctly(self):
n = 5
count = 0
@passive
def counter():
nonlocal count
while True:
yield
count += 1
def terminator():
for i in range(n):
yield
run_simulation(Module(), [counter(), terminator()])
self.assertEqual(count, n)