Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_array.py @ 8676:7d96842383bb legacy-trunk
Add tests for array self-assigns. (This one has no relevance to JPython.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 16 Jul 1998 15:31:43 +0000 |
| parents | aedd2d0dcb31 |
| children | b76df68099a5 |
line wrap: on
line diff
--- a/Lib/test/test_array.py Thu Jul 16 15:29:06 1998 +0000 +++ b/Lib/test/test_array.py Thu Jul 16 15:31:43 1998 +0000 @@ -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 @@ 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()
