tests: Add tests to improve coverage of runtime.c.
This commit is contained in:
parent
46a6592f9a
commit
531c206e8b
|
@ -99,3 +99,25 @@ try:
|
|||
g.close()
|
||||
except RuntimeError:
|
||||
print('RuntimeError')
|
||||
|
||||
# case where close is propagated up to a built-in iterator
|
||||
def gen8():
|
||||
g = reversed([2, 1])
|
||||
yield from g
|
||||
g = gen8()
|
||||
print(next(g))
|
||||
g.close()
|
||||
|
||||
# case with a user-defined close method
|
||||
class Iter:
|
||||
def __iter__(self):
|
||||
return self
|
||||
def __next__(self):
|
||||
return 1
|
||||
def close(self):
|
||||
print('close')
|
||||
def gen9():
|
||||
yield from Iter()
|
||||
g = gen9()
|
||||
print(next(g))
|
||||
g.close()
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# tests transition from small to large int representation by addition
|
||||
|
||||
# 31-bit overflow
|
||||
i = 0x3fffffff
|
||||
print(i + i)
|
||||
print(-i + -i)
|
||||
|
||||
# 63-bit overflow
|
||||
i = 0x3fffffffffffffff
|
||||
print(i + i)
|
||||
print(-i + -i)
|
|
@ -9,6 +9,15 @@ try:
|
|||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
# this class has no __next__ implementation
|
||||
class NotIterable:
|
||||
def __iter__(self):
|
||||
return self
|
||||
try:
|
||||
print(all(NotIterable()))
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
class MyStopIteration(StopIteration):
|
||||
pass
|
||||
|
||||
|
|
|
@ -22,6 +22,15 @@ try:
|
|||
except NameError:
|
||||
print("except 1")
|
||||
|
||||
# raised exception not contained in except tuple
|
||||
try:
|
||||
try:
|
||||
raise Exception
|
||||
except (RuntimeError, SyntaxError):
|
||||
print('except 2')
|
||||
except Exception:
|
||||
print('except 1')
|
||||
|
||||
# Check that exceptions across function boundaries work as expected
|
||||
def func1():
|
||||
try:
|
||||
|
|
|
@ -75,6 +75,12 @@ try:
|
|||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
#small int on LHS, complex on RHS, unsupported op
|
||||
try:
|
||||
print(1 | 1j)
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
# zero division
|
||||
try:
|
||||
1j / 0
|
||||
|
|
|
@ -87,6 +87,12 @@ try:
|
|||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
# small int on LHS, float on RHS, unsupported op
|
||||
try:
|
||||
print(1 | 1.0)
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
# can't convert list to float
|
||||
try:
|
||||
float([])
|
||||
|
|
Loading…
Reference in New Issue