tests/basic/: Make various tests skippable.
To run the testsuite on small ports.
This commit is contained in:
parent
b737c9cbc8
commit
f980c70997
|
@ -4,5 +4,4 @@ i = iter(iter([1, 2, 3]))
|
|||
print(list(i))
|
||||
i = iter(iter({1:2, 3:4, 5:6}))
|
||||
print(sorted(i))
|
||||
i = iter(iter({1, 2, 3}))
|
||||
print(sorted(i))
|
||||
# set, see set_iter_of_iter.py
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
print(list(map(lambda x: x & 1, range(-3, 4))))
|
||||
print(list(map(abs, range(-3, 4))))
|
||||
print(list(map(set, [[i] for i in range(-3, 4)])))
|
||||
print(list(map(tuple, [[i] for i in range(-3, 4)])))
|
||||
print(list(map(pow, range(4), range(4))))
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
# test memoryview
|
||||
try:
|
||||
memoryview
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
# test reading from bytes
|
||||
b = b'1234'
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# test memoryview accessing maximum values for signed/unsigned elements
|
||||
|
||||
from array import array
|
||||
try:
|
||||
from array import array
|
||||
memoryview
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
print(list(memoryview(b'\x7f\x80\x81\xff')))
|
||||
print(list(memoryview(array('b', [0x7f, -0x80]))))
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
# test memoryview retains pointer to original object/buffer
|
||||
try:
|
||||
memoryview
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
b = bytearray(10)
|
||||
m = memoryview(b)[1:]
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
try:
|
||||
from collections import namedtuple
|
||||
try:
|
||||
from collections import namedtuple
|
||||
except ImportError:
|
||||
from ucollections import namedtuple
|
||||
except ImportError:
|
||||
from ucollections import namedtuple
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
T = namedtuple("Tup", ["foo", "bar"])
|
||||
# CPython prints fully qualified name, what we don't bother to do so far
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
# (non-initialized) instance of class.
|
||||
# See e.g. http://infohost.nmt.edu/tcc/help/pubs/python/web/new-new-method.html
|
||||
# TODO: Find reference in CPython docs
|
||||
try:
|
||||
# If we don't expose object.__new__ (small ports), there's
|
||||
# nothing to test.
|
||||
object.__new__
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
class Foo:
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ test_exc("False in True", TypeError)
|
|||
test_exc("1 * {}", TypeError)
|
||||
test_exc("1 in 1", TypeError)
|
||||
test_exc("bytearray() // 2", TypeError)
|
||||
test_exc("m = memoryview(bytearray())\nm += bytearray()", TypeError)
|
||||
|
||||
# object with buffer protocol needed on rhs
|
||||
test_exc("bytearray(1) + 1", TypeError)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# test errors from bad operations (unary, binary, etc)
|
||||
try:
|
||||
memoryview
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
def test_exc(code, exc):
|
||||
try:
|
||||
exec(code)
|
||||
print("no exception")
|
||||
except exc:
|
||||
print("right exception")
|
||||
except:
|
||||
print("wrong exception")
|
||||
|
||||
# unsupported binary operators
|
||||
test_exc("m = memoryview(bytearray())\nm += bytearray()", TypeError)
|
|
@ -0,0 +1,2 @@
|
|||
i = iter(iter({1, 2, 3}))
|
||||
print(sorted(i))
|
|
@ -105,42 +105,4 @@ cud1 > cud2
|
|||
cud1 + cud2
|
||||
cud1 - cud2
|
||||
|
||||
# the following require MICROPY_PY_ALL_SPECIAL_METHODS
|
||||
+cud1
|
||||
-cud1
|
||||
~cud1
|
||||
cud1 * cud2
|
||||
cud1 / cud2
|
||||
cud2 // cud1
|
||||
cud1 += cud2
|
||||
cud1 -= cud2
|
||||
|
||||
# TODO: the following operations are not supported on every ports
|
||||
#
|
||||
# ne is not supported, !(eq) is called instead
|
||||
#cud1 != cud2
|
||||
#
|
||||
# binary and is not supported
|
||||
# cud1 & cud2
|
||||
#
|
||||
# binary lshift is not supported
|
||||
# cud1<<1
|
||||
#
|
||||
# modulus is not supported
|
||||
# cud1 % 2
|
||||
#
|
||||
# binary or is not supported
|
||||
# cud1 | cud2
|
||||
#
|
||||
# pow is not supported
|
||||
# cud1**2
|
||||
#
|
||||
# rshift is not suported
|
||||
# cud1>>1
|
||||
#
|
||||
# xor is not supported
|
||||
# cud1^cud2
|
||||
#
|
||||
# in the followin test, cpython still calls __eq__
|
||||
# cud3=cud1
|
||||
# cud3==cud1
|
||||
# more in special_methods2.py
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
class Cud():
|
||||
|
||||
def __init__(self):
|
||||
#print("__init__ called")
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
print("__repr__ called")
|
||||
return ""
|
||||
|
||||
def __lt__(self, other):
|
||||
print("__lt__ called")
|
||||
|
||||
def __le__(self, other):
|
||||
print("__le__ called")
|
||||
|
||||
def __eq__(self, other):
|
||||
print("__eq__ called")
|
||||
|
||||
def __ne__(self, other):
|
||||
print("__ne__ called")
|
||||
|
||||
def __ge__(self, other):
|
||||
print("__ge__ called")
|
||||
|
||||
def __gt__(self, other):
|
||||
print("__gt__ called")
|
||||
|
||||
def __abs__(self):
|
||||
print("__abs__ called")
|
||||
|
||||
def __add__(self, other):
|
||||
print("__add__ called")
|
||||
|
||||
def __and__(self, other):
|
||||
print("__and__ called")
|
||||
|
||||
def __floordiv__(self, other):
|
||||
print("__floordiv__ called")
|
||||
|
||||
def __index__(self, other):
|
||||
print("__index__ called")
|
||||
|
||||
def __inv__(self):
|
||||
print("__inv__ called")
|
||||
|
||||
def __invert__(self):
|
||||
print("__invert__ called")
|
||||
|
||||
def __lshift__(self, val):
|
||||
print("__lshift__ called")
|
||||
|
||||
def __mod__(self, val):
|
||||
print("__mod__ called")
|
||||
|
||||
def __mul__(self, other):
|
||||
print("__mul__ called")
|
||||
|
||||
def __matmul__(self, other):
|
||||
print("__matmul__ called")
|
||||
|
||||
def __neg__(self):
|
||||
print("__neg__ called")
|
||||
|
||||
def __or__(self, other):
|
||||
print("__or__ called")
|
||||
|
||||
def __pos__(self):
|
||||
print("__pos__ called")
|
||||
|
||||
def __pow__(self, val):
|
||||
print("__pow__ called")
|
||||
|
||||
def __rshift__(self, val):
|
||||
print("__rshift__ called")
|
||||
|
||||
def __sub__(self, other):
|
||||
print("__sub__ called")
|
||||
|
||||
def __truediv__(self, other):
|
||||
print("__truediv__ called")
|
||||
|
||||
def __div__(self, other):
|
||||
print("__div__ called")
|
||||
|
||||
def __xor__(self, other):
|
||||
print("__xor__ called")
|
||||
|
||||
def __iadd__(self, other):
|
||||
print("__iadd__ called")
|
||||
return self
|
||||
|
||||
def __isub__(self, other):
|
||||
print("__isub__ called")
|
||||
return self
|
||||
|
||||
cud1 = Cud()
|
||||
cud2 = Cud()
|
||||
|
||||
try:
|
||||
+cud1
|
||||
except TypeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
# the following require MICROPY_PY_ALL_SPECIAL_METHODS
|
||||
+cud1
|
||||
-cud1
|
||||
~cud1
|
||||
cud1 * cud2
|
||||
cud1 / cud2
|
||||
cud2 // cud1
|
||||
cud1 += cud2
|
||||
cud1 -= cud2
|
||||
|
||||
# TODO: the following operations are not supported on every ports
|
||||
#
|
||||
# ne is not supported, !(eq) is called instead
|
||||
#cud1 != cud2
|
||||
#
|
||||
# binary and is not supported
|
||||
# cud1 & cud2
|
||||
#
|
||||
# binary lshift is not supported
|
||||
# cud1<<1
|
||||
#
|
||||
# modulus is not supported
|
||||
# cud1 % 2
|
||||
#
|
||||
# binary or is not supported
|
||||
# cud1 | cud2
|
||||
#
|
||||
# pow is not supported
|
||||
# cud1**2
|
||||
#
|
||||
# rshift is not suported
|
||||
# cud1>>1
|
||||
#
|
||||
# xor is not supported
|
||||
# cud1^cud2
|
||||
#
|
||||
# in the followin test, cpython still calls __eq__
|
||||
# cud3=cud1
|
||||
# cud3==cud1
|
|
@ -5,6 +5,13 @@ class Base:
|
|||
def foo(cls):
|
||||
print(cls.__name__)
|
||||
|
||||
try:
|
||||
Base.__name__
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
class Sub(Base):
|
||||
pass
|
||||
|
||||
|
|
|
@ -6,8 +6,18 @@ print(sys.__name__)
|
|||
print(type(sys.path))
|
||||
print(type(sys.argv))
|
||||
print(sys.byteorder in ('little', 'big'))
|
||||
print(sys.maxsize > 100)
|
||||
print(sys.implementation.name in ('cpython', 'micropython'))
|
||||
|
||||
try:
|
||||
print(sys.maxsize > 100)
|
||||
except AttributeError:
|
||||
# Effectively skip subtests
|
||||
print(True)
|
||||
|
||||
try:
|
||||
print(sys.implementation.name in ('cpython', 'micropython'))
|
||||
except AttributeError:
|
||||
# Effectively skip subtests
|
||||
print(True)
|
||||
|
||||
try:
|
||||
sys.exit()
|
||||
|
|
Loading…
Reference in New Issue