neo-go/pkg/vm/compiler/tests/assign_test.go
Anthony De Meulemeester 2345858238
Compiler update (basic sc ready) (#31)
* refactored structs, the scope is not needed anymore + fix passing struct in func arguments.

* implemented byte arrays and added runtime tests

* Added sc examples in compiler README + added quick nested if test.

* Updated README
2018-02-27 10:04:24 +01:00

126 lines
2 KiB
Go

package compiler
var assignTestCases = []testCase{
{
"chain define",
`
package foo
func Main() int {
x := 4
y := x
z := y
foo := z
bar := foo
return bar
}
`,
"56c56b546c766b00527ac46c766b00c36c766b51527ac46c766b51c36c766b52527ac46c766b52c36c766b53527ac46c766b53c36c766b54527ac46203006c766b54c3616c7566",
},
{
"simple assign",
`
package foo
func Main() int {
x := 4
x = 8
return x
}
`,
"53c56b546c766b00527ac4586c766b00527ac46203006c766b00c3616c7566",
},
{
"add assign",
`
package foo
func Main() int {
x := 4
x += 8
return x
}
`,
"53c56b546c766b00527ac46c766b00c358936c766b00527ac46203006c766b00c3616c7566",
},
{
"sub assign",
`
package foo
func Main() int {
x := 4
x -= 2
return x
}
`,
"53c56b546c766b00527ac46c766b00c352946c766b00527ac46203006c766b00c3616c7566",
},
{
"mul assign",
`
package foo
func Main() int {
x := 4
x *= 2
return x
}
`,
"53c56b546c766b00527ac46c766b00c352956c766b00527ac46203006c766b00c3616c7566",
},
{
"div assign",
`
package foo
func Main() int {
x := 4
x /= 2
return x
}
`,
"53c56b546c766b00527ac46c766b00c352966c766b00527ac46203006c766b00c3616c7566",
},
{
"add assign binary expr",
`
package foo
func Main() int {
x := 4
x += 6 + 2
return x
}
`,
"53c56b546c766b00527ac46c766b00c358936c766b00527ac46203006c766b00c3616c7566",
},
{
"add assign binary expr ident",
`
package foo
func Main() int {
x := 4
y := 5
x += 6 + y
return x
}
`,
"54c56b546c766b00527ac4556c766b51527ac46c766b00c3566c766b51c393936c766b00527ac46203006c766b00c3616c7566",
},
{
"decl assign",
`
package foo
func Main() int {
var x int = 4
return x
}
`,
"52c56b546c766b00527ac46203006c766b00c3616c7566",
},
{
"multi assign",
`
package foo
func Main() int {
x, y := 1, 2
return x + y
}
`,
"53c56b516c766b00527ac4526c766b51527ac46203006c766b00c36c766b51c393616c7566",
},
}