compiler: emit Buffer for byte slices
All byte slices are mutable so buffer is a right stack item.
This commit is contained in:
parent
b4f1142149
commit
3a4ed7dfe8
3 changed files with 32 additions and 2 deletions
|
@ -180,6 +180,27 @@ var sliceTestCases = []testCase{
|
|||
vm.NewByteArrayItem([]byte("b")),
|
||||
},
|
||||
},
|
||||
{
|
||||
"byte-slice assignment",
|
||||
`package foo
|
||||
func Main() []byte {
|
||||
a := []byte{0, 1, 2}
|
||||
a[1] = 42
|
||||
return a
|
||||
}`,
|
||||
[]byte{0, 42, 2},
|
||||
},
|
||||
{
|
||||
"byte-slice assignment after string conversion",
|
||||
`package foo
|
||||
func Main() []byte {
|
||||
a := "abc"
|
||||
b := []byte(a)
|
||||
b[1] = 42
|
||||
return []byte(a)
|
||||
}`,
|
||||
[]byte{0x61, 0x62, 0x63},
|
||||
},
|
||||
}
|
||||
|
||||
func TestSliceOperations(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue