diff options
author | Ayke van Laethem <[email protected]> | 2019-08-02 12:19:23 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-08-04 17:51:16 +0200 |
commit | 4688664b4116283ffcc4d7652b6d8052f6dcdc60 (patch) | |
tree | b47587975da0fbf821238f017348ffc3c564dc1b /testdata | |
parent | 54169c714fb9e9142fed5e7a70897ff466f31d28 (diff) | |
download | tinygo-4688664b4116283ffcc4d7652b6d8052f6dcdc60.tar.gz tinygo-4688664b4116283ffcc4d7652b6d8052f6dcdc60.zip |
compiler: implement full slice expression
This feature was introduced in Go 1.2 and is used by some standard
library packages.
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/slice.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testdata/slice.go b/testdata/slice.go index 61ac1fb4b..8c5bae418 100644 --- a/testdata/slice.go +++ b/testdata/slice.go @@ -65,6 +65,20 @@ func main() { assert(len(arr[uint64(1):uint64(3)]) == 2) assert(len(arr[uintptr(1):uintptr(3)]) == 2) + // slicing with max parameter (added in Go 1.2) + longfoo := []int{1, 2, 4, 5, 10, 11} + assert(cap(longfoo[int(1):int(3):int(5)]) == 4) + assert(cap(longfoo[int8(1):int8(3):int8(5)]) == 4) + assert(cap(longfoo[int16(1):int16(3):int16(5)]) == 4) + assert(cap(longfoo[int32(1):int32(3):int32(5)]) == 4) + assert(cap(longfoo[int64(1):int64(3):int64(5)]) == 4) + assert(cap(longfoo[uint(1):uint(3):uint(5)]) == 4) + assert(cap(longfoo[uint8(1):uint8(3):uint8(5)]) == 4) + assert(cap(longfoo[uint16(1):uint16(3):uint16(5)]) == 4) + assert(cap(longfoo[uint32(1):uint32(3):uint32(5)]) == 4) + assert(cap(longfoo[uint64(1):uint64(3):uint64(5)]) == 4) + assert(cap(longfoo[uintptr(1):uintptr(3):uintptr(5)]) == 4) + // copy println("copy foo -> bar:", copy(bar, foo)) printslice("bar", bar) |