compiler: support creating slices with uncommon initial len/cap types

This commit is contained in:
Ayke van Laethem
2018-11-18 18:34:09 +01:00
parent 9181f2d4ce
commit 8cb7b583d8
2 changed files with 27 additions and 0 deletions
+13
View File
@@ -10,6 +10,19 @@ func main() {
printslice("foo[1:2]", foo[1:2])
println("sum foo:", sum(foo))
// creating a slice with uncommon len, cap types
assert(len(make([]int, int(2), int(3))) == 2)
assert(len(make([]int, int8(2), int8(3))) == 2)
assert(len(make([]int, int16(2), int16(3))) == 2)
assert(len(make([]int, int32(2), int32(3))) == 2)
assert(len(make([]int, int64(2), int64(3))) == 2)
assert(len(make([]int, uint(2), uint(3))) == 2)
assert(len(make([]int, uint8(2), uint8(3))) == 2)
assert(len(make([]int, uint16(2), uint16(3))) == 2)
assert(len(make([]int, uint32(2), uint32(3))) == 2)
assert(len(make([]int, uint64(2), uint64(3))) == 2)
assert(len(make([]int, uintptr(2), uintptr(3))) == 2)
// indexing into a slice with uncommon index types
assert(foo[int(2)] == 4)
assert(foo[int8(2)] == 4)