tests: Add some tests to improve coverage.
Used gcov to find some parts of vm.c, runtime.c, obj.c that were not covered by any tests. Still need to use gcov more thoroughly.
This commit is contained in:
parent
81e70a88a7
commit
12c66be2b8
|
@ -1,5 +1,16 @@
|
||||||
# test builtin hash function
|
# test builtin hash function
|
||||||
|
|
||||||
|
print(hash(False))
|
||||||
|
print(hash(True))
|
||||||
|
print({():1}) # hash tuple
|
||||||
|
print({1 << 66:1}) # hash big int
|
||||||
|
print(hash in {hash:1}) # hash function
|
||||||
|
|
||||||
|
try:
|
||||||
|
hash([])
|
||||||
|
except TypeError:
|
||||||
|
print("TypeError")
|
||||||
|
|
||||||
class A:
|
class A:
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return 123
|
return 123
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# del global
|
||||||
|
|
||||||
|
def do_del():
|
||||||
|
global x
|
||||||
|
del x
|
||||||
|
|
||||||
|
x = 1
|
||||||
|
print(x)
|
||||||
|
do_del()
|
||||||
|
try:
|
||||||
|
print(x)
|
||||||
|
except NameError:
|
||||||
|
print("NameError")
|
||||||
|
try:
|
||||||
|
do_del()
|
||||||
|
except: # NameError:
|
||||||
|
# FIXME uPy returns KeyError for this
|
||||||
|
print("NameError")
|
|
@ -1,4 +1,4 @@
|
||||||
# del global
|
# del name
|
||||||
|
|
||||||
x = 1
|
x = 1
|
||||||
print(x)
|
print(x)
|
||||||
|
|
|
@ -129,5 +129,9 @@ def f():
|
||||||
x125 = 1
|
x125 = 1
|
||||||
x126 = 1
|
x126 = 1
|
||||||
|
|
||||||
|
f()
|
||||||
|
|
||||||
def g():
|
def g():
|
||||||
x = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,]
|
x = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,]
|
||||||
|
|
||||||
|
g()
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
print(int(False))
|
||||||
|
print(int(True))
|
||||||
|
|
||||||
print(int(0))
|
print(int(0))
|
||||||
print(int(1))
|
print(int(1))
|
||||||
print(int(+1))
|
print(int(+1))
|
||||||
|
|
|
@ -49,6 +49,15 @@ print(a)
|
||||||
# This would overflow
|
# This would overflow
|
||||||
#a -= 1
|
#a -= 1
|
||||||
|
|
||||||
|
# negative shifts are not allowed
|
||||||
|
try:
|
||||||
|
a << -1
|
||||||
|
except ValueError:
|
||||||
|
print("ValueError")
|
||||||
|
try:
|
||||||
|
a >> -1
|
||||||
|
except ValueError:
|
||||||
|
print("ValueError")
|
||||||
|
|
||||||
# Shifts to big amounts are undefined behavior in C and is CPU-specific
|
# Shifts to big amounts are undefined behavior in C and is CPU-specific
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
x = 1
|
||||||
|
print(+x)
|
||||||
|
print(-x)
|
||||||
|
print(~x)
|
||||||
|
|
||||||
print(not None)
|
print(not None)
|
||||||
print(not False)
|
print(not False)
|
||||||
print(not True)
|
print(not True)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# negative power should produce float
|
||||||
|
|
||||||
|
x = 2
|
||||||
|
print(x ** -2)
|
||||||
|
|
||||||
|
x = 3
|
||||||
|
x **= -2
|
||||||
|
print(x)
|
Loading…
Reference in New Issue