kopia lustrzana https://github.com/micropython/micropython
tests/basics: Add test for use of return within try-except.
The case of a return statement in the try suite of a try-except statement was previously only tested by builtin_compile.py, and only then in the part of this test which checked for the existence of the compile builtin. So this patch adds an explicit unit test for this case.pull/3691/merge
rodzic
bc36521386
commit
430efb0444
|
@ -0,0 +1,11 @@
|
|||
# test use of return with try-except
|
||||
|
||||
def f(l, i):
|
||||
try:
|
||||
return l[i]
|
||||
except IndexError:
|
||||
print('IndexError')
|
||||
return -1
|
||||
|
||||
print(f([1], 0))
|
||||
print(f([], 0))
|
Ładowanie…
Reference in New Issue