tests: Add tests for op special meths, ubinascii, complex.
This commit is contained in:
parent
18fd7e8305
commit
2af921fb51
|
@ -12,5 +12,3 @@ print(d['1'], d['2'], d['3'])
|
|||
d2 = dict(d)
|
||||
print('2' in d2)
|
||||
print(id(d) != id(d2), d == d2)
|
||||
|
||||
print(d.__getitem__('2'))
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# dict object with special methods
|
||||
|
||||
d = {}
|
||||
d.__setitem__('2', 'two')
|
||||
print(d.__getitem__('2'))
|
||||
d.__delitem__('2')
|
||||
print(d)
|
|
@ -0,0 +1,5 @@
|
|||
# set object with special methods
|
||||
|
||||
s = {1, 2}
|
||||
print(s.__contains__(1))
|
||||
print(s.__contains__(3))
|
|
@ -0,0 +1,9 @@
|
|||
try:
|
||||
import ubinascii as binascii
|
||||
except ImportError:
|
||||
import binascii
|
||||
|
||||
print(binascii.hexlify(b'\x00\x01\x02\x03\x04\x05\x06\x07'))
|
||||
print(binascii.hexlify(b'\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'))
|
||||
print(binascii.hexlify(b'\x7f\x80\xff'))
|
||||
print(binascii.hexlify(b'1234ABCDabcd'))
|
|
@ -0,0 +1,28 @@
|
|||
# test basic complex number functionality
|
||||
|
||||
# constructor
|
||||
print(complex(1))
|
||||
print(complex(1.2))
|
||||
print(complex(1.2j))
|
||||
print(complex("1"))
|
||||
print(complex("1.2"))
|
||||
print(complex("1.2j"))
|
||||
print(complex(1, 2))
|
||||
print(complex(1j, 2j))
|
||||
|
||||
# unary ops
|
||||
print(bool(1j))
|
||||
print(+(1j))
|
||||
#print(-(1j)) uPy doesn't print correctly
|
||||
|
||||
# binary ops
|
||||
print(1j + 2)
|
||||
print(1j + 2j)
|
||||
print(1j - 2)
|
||||
print(1j - 2j)
|
||||
print(1j * 2)
|
||||
print(1j * 2j)
|
||||
print(1j / 2)
|
||||
#print(1j / 2j) uPy doesn't print correctly
|
||||
#print(1j ** 2) uPy doesn't print correctly
|
||||
#print(1j ** 2j) uPy doesn't print correctly
|
Loading…
Reference in New Issue