diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-11-30 00:00:55 +0000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-11-30 00:00:55 +0000 |
| commit | b2e731177e96e55f202811968725b128ca13d861 (patch) | |
| tree | 847b6cd4b524c2c14e6fb1ad24350017a15cecd1 /tests | |
| parent | 19fb1b4dd7173ad2cf4b2bb1b0f0c06498499bd2 (diff) | |
py: Implement +, += and .extend for bytearray and array objs.
Addresses issue #994.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basics/array_add.py | 12 | ||||
| -rw-r--r-- | tests/basics/bytearray_add.py | 14 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/basics/array_add.py b/tests/basics/array_add.py new file mode 100644 index 000000000..1dba8a3bc --- /dev/null +++ b/tests/basics/array_add.py @@ -0,0 +1,12 @@ +# test array + array +import array + +a1 = array.array('I', [1]) +a2 = array.array('I', [2]) +print(a1 + a2) + +a1 += array.array('I', [3, 4]) +print(a1) + +a1.extend(array.array('I', [5])) +print(a1) diff --git a/tests/basics/bytearray_add.py b/tests/basics/bytearray_add.py new file mode 100644 index 000000000..21a386c6e --- /dev/null +++ b/tests/basics/bytearray_add.py @@ -0,0 +1,14 @@ +# test bytearray + bytearray + +b = bytearray(2) +b[0] = 1 +b[1] = 2 +print(b + bytearray(2)) + +# inplace add +b += bytearray(3) +print(b) + +# extend +b.extend(bytearray(4)) +print(b) |
