From decd597273c39311541bfd45ab71974f90dca9e6 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 20 Jan 2014 18:38:27 +0200 Subject: unix io.FileIO: Add iteration support. A file cannot be iterated concurrently, so we make io.FileIO its own iterator. --- tests/io/file-iter.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/io/file-iter.py (limited to 'tests') diff --git a/tests/io/file-iter.py b/tests/io/file-iter.py new file mode 100644 index 000000000..48e873996 --- /dev/null +++ b/tests/io/file-iter.py @@ -0,0 +1,3 @@ +f = open("io/data/file1") +for l in f: + print(l) -- cgit v1.2.3 From 545591a696bdff73f68573c54a05ca70eb58032d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 21 Jan 2014 00:27:33 +0200 Subject: Implement string multiplication. --- tests/basics/string1.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/basics/string1.py b/tests/basics/string1.py index 3fecf799b..40e766b59 100644 --- a/tests/basics/string1.py +++ b/tests/basics/string1.py @@ -8,6 +8,8 @@ print(x) print('123' + "456") +print('123' * 5) + # iter print(list('str')) -- cgit v1.2.3 From 7380a837802b4630bdcef6e01cd5be32f92750ca Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 21 Jan 2014 02:22:02 +0200 Subject: str: Implement proper string (instead of byte string) indexing. Also, support negative indexes. --- tests/basics/string1.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/basics/string1.py b/tests/basics/string1.py index 40e766b59..074b04ef8 100644 --- a/tests/basics/string1.py +++ b/tests/basics/string1.py @@ -10,6 +10,17 @@ print('123' + "456") print('123' * 5) +print('abc'[1]) +print('abc'[-1]) +try: + 'abc'[100] +except IndexError: + print('caught') +try: + 'abc'[-4] +except IndexError: + print('caught2') + # iter print(list('str')) -- cgit v1.2.3 From 4c316552c16fa2bcb77e007d330dc32beaf6e652 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 21 Jan 2014 05:00:21 +0200 Subject: Implement str.split(None). Note that splitting by explicit string is not implemented so far. --- tests/basics/string_split.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/basics/string_split.py (limited to 'tests') diff --git a/tests/basics/string_split.py b/tests/basics/string_split.py new file mode 100644 index 000000000..f73cb4291 --- /dev/null +++ b/tests/basics/string_split.py @@ -0,0 +1,7 @@ +print("a b".split()) +print(" a b ".split(None)) +print(" a b ".split(None, 1)) +print(" a b ".split(None, 2)) +print(" a b c ".split(None, 1)) +print(" a b c ".split(None, 0)) +print(" a b c ".split(None, -1)) -- cgit v1.2.3 From 7280f790881fa174e4d234266ff42f0fe3d847bc Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 21 Jan 2014 04:58:34 +0200 Subject: run-tests: Allow to run tests selectively via command line. --- tests/run-tests | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/run-tests b/tests/run-tests index ef1368725..752138ccc 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -10,7 +10,14 @@ numpassed=0 numfailed=0 namefailed= -for infile in basics/*.py io/*.py +if [ $# -eq 0 ] +then + tests="basics/*.py io/*.py" +else + tests="$@" +fi + +for infile in $tests do basename=`basename $infile .py` outfile=${basename}.out -- cgit v1.2.3