diff options
author | Ayke van Laethem <[email protected]> | 2019-08-11 14:30:43 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-08-11 15:37:05 +0200 |
commit | fea56d4164ba832dd0f6798cb267ac2fe8b6321a (patch) | |
tree | ed59af9fb57d3fd8b7ef1d38ab8f3ddc17b94614 /testdata/slice.go | |
parent | ea8e4079bcade515fe8ca4f44326ee7f9bd4da39 (diff) | |
download | tinygo-fea56d4164ba832dd0f6798cb267ac2fe8b6321a.tar.gz tinygo-fea56d4164ba832dd0f6798cb267ac2fe8b6321a.zip |
compiler: add support for full slice expression for slicing arrays
This was an oversight in the main commit for full slice expressions:
https://github.com/tinygo-org/tinygo/pull/472
This syntax is used by the regexp package, for example.
Diffstat (limited to 'testdata/slice.go')
-rw-r--r-- | testdata/slice.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/testdata/slice.go b/testdata/slice.go index 8c5bae418..8182af36d 100644 --- a/testdata/slice.go +++ b/testdata/slice.go @@ -79,6 +79,19 @@ func main() { assert(cap(longfoo[uint64(1):uint64(3):uint64(5)]) == 4) assert(cap(longfoo[uintptr(1):uintptr(3):uintptr(5)]) == 4) + // slicing an array with max parameter (added in Go 1.2) + assert(cap(arr[int(1):int(2):int(4)]) == 3) + assert(cap(arr[int8(1):int8(2):int8(4)]) == 3) + assert(cap(arr[int16(1):int16(2):int16(4)]) == 3) + assert(cap(arr[int32(1):int32(2):int32(4)]) == 3) + assert(cap(arr[int64(1):int64(2):int64(4)]) == 3) + assert(cap(arr[uint(1):uint(2):uint(4)]) == 3) + assert(cap(arr[uint8(1):uint8(2):uint8(4)]) == 3) + assert(cap(arr[uint16(1):uint16(2):uint16(4)]) == 3) + assert(cap(arr[uint32(1):uint32(2):uint32(4)]) == 3) + assert(cap(arr[uint64(1):uint64(2):uint64(4)]) == 3) + assert(cap(arr[uintptr(1):uintptr(2):uintptr(4)]) == 3) + // copy println("copy foo -> bar:", copy(bar, foo)) printslice("bar", bar) |