mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 09:02:28 +00:00
compiler: support variables in slice literals
This commit is contained in:
parent
eb59460032
commit
def73db8e9
2 changed files with 25 additions and 2 deletions
|
@ -45,9 +45,32 @@ var sliceTestCases = []testCase{
|
|||
`,
|
||||
big.NewInt(9),
|
||||
},
|
||||
{
|
||||
"slice literals with variables",
|
||||
`
|
||||
package foo
|
||||
func Main() int {
|
||||
elem := 7
|
||||
a := []int{6, elem, 8}
|
||||
return a[1]
|
||||
}
|
||||
`,
|
||||
big.NewInt(7),
|
||||
},
|
||||
{
|
||||
"slice literals with expressions",
|
||||
`
|
||||
package foo
|
||||
func Main() int {
|
||||
elem := []int{3, 7}
|
||||
a := []int{6, elem[1]*2+1, 24}
|
||||
return a[1]
|
||||
}
|
||||
`,
|
||||
big.NewInt(15),
|
||||
},
|
||||
}
|
||||
|
||||
func TestSliceOperations(t *testing.T) {
|
||||
runTestCases(t, sliceTestCases)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue