MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / test_setInterval_unref

Function test_setInterval_unref

tests/python/test_event_loop.py:22–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20
21
22def test_setInterval_unref():
23 async def async_fn():
24 obj = {'val': 0}
25 pm.eval("""(obj) => {
26 setInterval(()=>{ obj.val++ }, 200).unref()
27 setTimeout(()=>{ }, 500)
28 }""")(obj)
29 await pm.wait() # It should stop after the setTimeout timer's 500ms.
30 assert obj['val'] == 2 # The setInterval timer should only run twice (500 // 200 == 2)
31 return True
32 assert asyncio.run(async_fn())
33
34
35def test_clearInterval():

Callers

nothing calls this directly

Calls 1

async_fnFunction · 0.70

Tested by

no test coverage detected