tests: Add some tests to improve coverage.
This commit is contained in:
parent
598af3a7d6
commit
92ab95f215
6
tests/basics/builtin_ellipsis.py
Normal file
6
tests/basics/builtin_ellipsis.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# tests that .../Ellipsis exists
|
||||||
|
|
||||||
|
print(...)
|
||||||
|
print(Ellipsis)
|
||||||
|
|
||||||
|
print(... == Ellipsis)
|
@ -1,5 +1,6 @@
|
|||||||
# test large function (stack) state
|
# test large function (stack) state
|
||||||
|
|
||||||
|
# this function creates 127 locals
|
||||||
def f():
|
def f():
|
||||||
x0 = 1
|
x0 = 1
|
||||||
x1 = 1
|
x1 = 1
|
||||||
@ -128,10 +129,31 @@ def f():
|
|||||||
x124 = 1
|
x124 = 1
|
||||||
x125 = 1
|
x125 = 1
|
||||||
x126 = 1
|
x126 = 1
|
||||||
|
|
||||||
f()
|
f()
|
||||||
|
|
||||||
|
# this function pushes 128 elements onto the function stack
|
||||||
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()
|
g()
|
||||||
|
|
||||||
|
# this function exercises load_fast_n and store_fast_n opcodes
|
||||||
|
def h():
|
||||||
|
x0 = 1
|
||||||
|
x1 = x0
|
||||||
|
x2 = x1
|
||||||
|
x3 = x2
|
||||||
|
x4 = x3
|
||||||
|
x5 = x4
|
||||||
|
x6 = x5
|
||||||
|
x7 = x6
|
||||||
|
x8 = x7
|
||||||
|
x9 = x8
|
||||||
|
x10 = x9
|
||||||
|
x11 = x10
|
||||||
|
x12 = x11
|
||||||
|
x13 = x12
|
||||||
|
x14 = x13
|
||||||
|
x15 = x14
|
||||||
|
x16 = x15
|
||||||
|
x17 = x16
|
||||||
|
h()
|
||||||
|
@ -16,3 +16,7 @@ print(x[a::])
|
|||||||
print(x[a:b])
|
print(x[a:b])
|
||||||
print(x[a:b:])
|
print(x[a:b:])
|
||||||
#print(x[a:b:c])
|
#print(x[a:b:c])
|
||||||
|
|
||||||
|
# these should not raise IndexError
|
||||||
|
print([][1:])
|
||||||
|
print([][-1:])
|
||||||
|
6
tests/io/file_readline.py
Normal file
6
tests/io/file_readline.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
f = open("io/data/file1")
|
||||||
|
print(f.readline())
|
||||||
|
print(f.readline(3))
|
||||||
|
print(f.readline(4))
|
||||||
|
print(f.readline(5))
|
||||||
|
print(f.readline())
|
@ -1 +1,2 @@
|
|||||||
aαbβcγdδ
|
aαbβcγdδ
|
||||||
|
ぁ🙐
|
||||||
|
@ -10,6 +10,16 @@ def do(mode):
|
|||||||
print(f.read(1))
|
print(f.read(1))
|
||||||
print(f.read(2))
|
print(f.read(2))
|
||||||
print(f.read(4))
|
print(f.read(4))
|
||||||
|
|
||||||
|
# skip to end of line
|
||||||
|
f.readline()
|
||||||
|
|
||||||
|
# check 3-byte utf-8 char
|
||||||
|
print(f.read(1 if mode == 'rt' else 3))
|
||||||
|
|
||||||
|
# check 4-byte utf-8 char
|
||||||
|
print(f.read(1 if mode == 'rt' else 4))
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
do('rb')
|
do('rb')
|
||||||
|
Loading…
Reference in New Issue
Block a user