tests: Add 6 tests for async await/for/with.

This commit is contained in:
Damien George
2016-04-13 15:27:06 +01:00
parent eacbd7aeba
commit c33df193bf
6 changed files with 175 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
# test await expression
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types
coroutine = types.coroutine
@coroutine
def wait(value):
print('wait value:', value)
msg = yield 'message from wait(%u)' % value
print('wait got back:', msg)
return 10
async def f():
x = await wait(1)**2
print('x =', x)
coro = f()
print('return from send:', coro.send(None))
try:
coro.send('message from main')
except StopIteration:
print('got StopIteration')