From 92ab95f21539d94c2139974b3995699a155f5a97 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 29 Jan 2015 14:56:09 +0000 Subject: [PATCH] tests: Add some tests to improve coverage. --- tests/basics/builtin_ellipsis.py | 6 ++++++ tests/basics/fun_largestate.py | 26 ++++++++++++++++++++++++-- tests/basics/list_slice.py | 4 ++++ tests/io/file_readline.py | 6 ++++++ tests/unicode/data/utf-8_2.txt | 1 + tests/unicode/file2.py | 10 ++++++++++ 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/basics/builtin_ellipsis.py create mode 100644 tests/io/file_readline.py diff --git a/tests/basics/builtin_ellipsis.py b/tests/basics/builtin_ellipsis.py new file mode 100644 index 0000000000..d88647a89a --- /dev/null +++ b/tests/basics/builtin_ellipsis.py @@ -0,0 +1,6 @@ +# tests that .../Ellipsis exists + +print(...) +print(Ellipsis) + +print(... == Ellipsis) diff --git a/tests/basics/fun_largestate.py b/tests/basics/fun_largestate.py index f13619295f..124f1e506f 100644 --- a/tests/basics/fun_largestate.py +++ b/tests/basics/fun_largestate.py @@ -1,5 +1,6 @@ # test large function (stack) state +# this function creates 127 locals def f(): x0 = 1 x1 = 1 @@ -128,10 +129,31 @@ def f(): x124 = 1 x125 = 1 x126 = 1 - f() +# this function pushes 128 elements onto the function stack 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,] - 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() diff --git a/tests/basics/list_slice.py b/tests/basics/list_slice.py index a9962132e2..3a9a1e05e6 100644 --- a/tests/basics/list_slice.py +++ b/tests/basics/list_slice.py @@ -16,3 +16,7 @@ print(x[a::]) print(x[a:b]) print(x[a:b:]) #print(x[a:b:c]) + +# these should not raise IndexError +print([][1:]) +print([][-1:]) diff --git a/tests/io/file_readline.py b/tests/io/file_readline.py new file mode 100644 index 0000000000..c6a67d0e15 --- /dev/null +++ b/tests/io/file_readline.py @@ -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()) diff --git a/tests/unicode/data/utf-8_2.txt b/tests/unicode/data/utf-8_2.txt index ab0eaa4e0d..6f142974e7 100644 --- a/tests/unicode/data/utf-8_2.txt +++ b/tests/unicode/data/utf-8_2.txt @@ -1 +1,2 @@ aαbβcγdδ +ぁ🙐 diff --git a/tests/unicode/file2.py b/tests/unicode/file2.py index b8a3419660..8c45f91faf 100644 --- a/tests/unicode/file2.py +++ b/tests/unicode/file2.py @@ -10,6 +10,16 @@ def do(mode): print(f.read(1)) print(f.read(2)) 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() do('rb')