From 26534cec8510323e8d1a313991b76320821c666b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 3 Jan 2014 23:38:16 +0200 Subject: Add test for byte string slicing. --- tests/basics/tests/slice-bstr1.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/basics/tests/slice-bstr1.py (limited to 'tests') diff --git a/tests/basics/tests/slice-bstr1.py b/tests/basics/tests/slice-bstr1.py new file mode 100644 index 000000000..8b492b35c --- /dev/null +++ b/tests/basics/tests/slice-bstr1.py @@ -0,0 +1,27 @@ +b"123"[0:1] + +b"123"[0:2] + +b"123"[:1] + +b"123"[1:] + +# Idiom for copying sequence +b"123"[:] + +b"123"[:-1] + +# Weird cases +b"123"[0:0] +b"123"[1:0] +b"123"[1:1] +b"123"[-1:-1] +b"123"[-3:] +b"123"[-3:3] +b"123"[0:] +b"123"[:0] +b"123"[:-3] +b"123"[:-4] +# No IndexError! +b""[1:1] +b""[-1:-1] -- cgit v1.2.3 From c8d1384fc0c7aafa5dee3445ece20f4e43dfa9c1 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 4 Jan 2014 01:06:10 +0000 Subject: Fix int -> machine_int_t; add print to slice test. --- tests/basics/tests/slice-bstr1.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/basics/tests/slice-bstr1.py b/tests/basics/tests/slice-bstr1.py index 8b492b35c..0bed95914 100644 --- a/tests/basics/tests/slice-bstr1.py +++ b/tests/basics/tests/slice-bstr1.py @@ -1,27 +1,27 @@ -b"123"[0:1] +print(b"123"[0:1]) -b"123"[0:2] +print(b"123"[0:2]) -b"123"[:1] +print(b"123"[:1]) -b"123"[1:] +print(b"123"[1:]) # Idiom for copying sequence -b"123"[:] +print(b"123"[:]) -b"123"[:-1] +print(b"123"[:-1]) # Weird cases -b"123"[0:0] -b"123"[1:0] -b"123"[1:1] -b"123"[-1:-1] -b"123"[-3:] -b"123"[-3:3] -b"123"[0:] -b"123"[:0] -b"123"[:-3] -b"123"[:-4] +print(b"123"[0:0]) +print(b"123"[1:0]) +print(b"123"[1:1]) +print(b"123"[-1:-1]) +print(b"123"[-3:]) +print(b"123"[-3:3]) +print(b"123"[0:]) +print(b"123"[:0]) +print(b"123"[:-3]) +print(b"123"[:-4]) # No IndexError! -b""[1:1] -b""[-1:-1] +print(b""[1:1]) +print(b""[-1:-1]) -- cgit v1.2.3 From 6ee1e383d6b95d0bb5f2902ec91b8d831e4b5803 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 4 Jan 2014 03:47:34 +0200 Subject: str slice: Trim slice indexes to be in range. --- tests/basics/tests/slice-bstr1.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/basics/tests/slice-bstr1.py b/tests/basics/tests/slice-bstr1.py index 0bed95914..74dbc2061 100644 --- a/tests/basics/tests/slice-bstr1.py +++ b/tests/basics/tests/slice-bstr1.py @@ -22,6 +22,11 @@ print(b"123"[0:]) print(b"123"[:0]) print(b"123"[:-3]) print(b"123"[:-4]) +# Range check testing, don't segfault, please ;-) +print(b"123"[:1000000]) +print(b"123"[1000000:]) +print(b"123"[:-1000000]) +print(b"123"[-1000000:]) # No IndexError! print(b""[1:1]) print(b""[-1:-1]) -- cgit v1.2.3 From 21dfb55dadb01b135edca9b66ca6b53a82bec60a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 4 Jan 2014 19:06:34 +0200 Subject: tests/basics requires python3.3 tests/bytecode/run-tests already uses puthon3.3, so let's just use it here too. Fore reference, errors with python 3.2.3: File "tests/generator1.py", line 12 return None SyntaxError: 'return' with argument inside generator File "tests/list_clear.py", line 3, in x.clear() AttributeError: 'list' object has no attribute 'clear' etc. --- tests/basics/run-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/basics/run-tests b/tests/basics/run-tests index 72e69c2d8..0037b1304 100755 --- a/tests/basics/run-tests +++ b/tests/basics/run-tests @@ -1,7 +1,7 @@ #!/usr/bin/env bash RM="/bin/rm -f" -CPYTHON3=python3 +CPYTHON3=python3.3 MP_PY=../../unix/py numtests=0 -- cgit v1.2.3 From 9464cde3c94b1c69a9cf433d8b0ac8a7c78f8bf1 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 4 Jan 2014 19:12:05 +0200 Subject: Unbreak string slice test by just switching to normal (not byte) strings. --- tests/basics/tests/slice-bstr1.py | 32 -------------------------------- tests/basics/tests/string-slice.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 tests/basics/tests/slice-bstr1.py create mode 100644 tests/basics/tests/string-slice.py (limited to 'tests') diff --git a/tests/basics/tests/slice-bstr1.py b/tests/basics/tests/slice-bstr1.py deleted file mode 100644 index 74dbc2061..000000000 --- a/tests/basics/tests/slice-bstr1.py +++ /dev/null @@ -1,32 +0,0 @@ -print(b"123"[0:1]) - -print(b"123"[0:2]) - -print(b"123"[:1]) - -print(b"123"[1:]) - -# Idiom for copying sequence -print(b"123"[:]) - -print(b"123"[:-1]) - -# Weird cases -print(b"123"[0:0]) -print(b"123"[1:0]) -print(b"123"[1:1]) -print(b"123"[-1:-1]) -print(b"123"[-3:]) -print(b"123"[-3:3]) -print(b"123"[0:]) -print(b"123"[:0]) -print(b"123"[:-3]) -print(b"123"[:-4]) -# Range check testing, don't segfault, please ;-) -print(b"123"[:1000000]) -print(b"123"[1000000:]) -print(b"123"[:-1000000]) -print(b"123"[-1000000:]) -# No IndexError! -print(b""[1:1]) -print(b""[-1:-1]) diff --git a/tests/basics/tests/string-slice.py b/tests/basics/tests/string-slice.py new file mode 100644 index 000000000..7538ae570 --- /dev/null +++ b/tests/basics/tests/string-slice.py @@ -0,0 +1,32 @@ +print("123"[0:1]) + +print("123"[0:2]) + +print("123"[:1]) + +print("123"[1:]) + +# Idiom for copying sequence +print("123"[:]) + +print("123"[:-1]) + +# Weird cases +print("123"[0:0]) +print("123"[1:0]) +print("123"[1:1]) +print("123"[-1:-1]) +print("123"[-3:]) +print("123"[-3:3]) +print("123"[0:]) +print("123"[:0]) +print("123"[:-3]) +print("123"[:-4]) +# Range check testing, don't segfault, please ;-) +print("123"[:1000000]) +print("123"[1000000:]) +print("123"[:-1000000]) +print("123"[-1000000:]) +# No IndexError! +print(""[1:1]) +print(""[-1:-1]) -- cgit v1.2.3