forked from TrueCloudLab/neoneo-go
23cfebf621
* implemented add, mul, div, sub assign for identifiers. * Implemented struct field initialization. * Implemented imports * Implemented storage VM API (interop layer) + additional bug fixes when encountered. * Bumped version 0.12.0 * fixed double point extension on compiled output file. * Fixed bug where callExpr in returns where added to voidCall * fixed binExpr compare equal * Check the env for the gopath first * removed travis.yml * custom types + implemented general declarations. * commented out the storage test to make the build pass
115 lines
1.8 KiB
Go
115 lines
1.8 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",
|
|
},
|
|
}
|