diff options
author | Guido van Rossum <guido@python.org> | 1998-07-16 15:31:43 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-07-16 15:31:43 (GMT) |
commit | 7f1d3aa3d957aaa358bb41086980cac3d17614f7 (patch) | |
tree | 9ae28c100fd5023ab62494de1a8bd5586704cb49 | |
parent | affd77f71e7f24aa7a376ca6c6724581deb1b6cd (diff) | |
download | cpython-7f1d3aa3d957aaa358bb41086980cac3d17614f7.zip cpython-7f1d3aa3d957aaa358bb41086980cac3d17614f7.tar.gz cpython-7f1d3aa3d957aaa358bb41086980cac3d17614f7.tar.bz2 |
Add tests for array self-assigns. (This one has no relevance to JPython.)
-rwxr-xr-x | Lib/test/test_array.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 6a0d17c..1e0f1be 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -3,7 +3,7 @@ Roger E. Masse """ import array -from test_support import verbose, TESTFN, unlink +from test_support import verbose, TESTFN, unlink, TestFailed def main(): @@ -54,6 +54,33 @@ def testtype(type, example): print 'array of %s converted to a string: ' \ % a.typecode, `a.tostring()` + if type == 'c': + a = array.array(type, "abcde") + a[:-1] = a + if a != array.array(type, "abcdee"): + raise TestFailed, "array(%s) self-slice-assign (head)" % `type` + a = array.array(type, "abcde") + a[1:] = a + if a != array.array(type, "aabcde"): + raise TestFailed, "array(%s) self-slice-assign (tail)" % `type` + a = array.array(type, "abcde") + a[1:-1] = a + if a != array.array(type, "aabcdee"): + raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` + else: + a = array.array(type, [1, 2, 3, 4, 5]) + a[:-1] = a + if a != array.array(type, [1, 2, 3, 4, 5, 5]): + raise TestFailed, "array(%s) self-slice-assign (head)" % `type` + a = array.array(type, [1, 2, 3, 4, 5]) + a[1:] = a + if a != array.array(type, [1, 1, 2, 3, 4, 5]): + raise TestFailed, "array(%s) self-slice-assign (tail)" % `type` + a = array.array(type, [1, 2, 3, 4, 5]) + a[1:-1] = a + if a != array.array(type, [1, 1, 2, 3, 4, 5, 5]): + raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` + main() |