mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: allow to convert string constants to []byte
Also load constant directly into stack, not by name.
This commit is contained in:
parent
1cfad9ccb8
commit
d65d6ab08d
2 changed files with 30 additions and 5 deletions
|
@ -54,3 +54,28 @@ func TestByteConversionDirectlyInFunctionCall(t *testing.T) {
|
|||
`
|
||||
eval(t, src, []byte("foo"))
|
||||
}
|
||||
|
||||
func TestByteConversionOfConstant(t *testing.T) {
|
||||
src := `
|
||||
package foo
|
||||
const foo = "foo"
|
||||
func Main() []byte {
|
||||
b := []byte(foo)
|
||||
return b
|
||||
}
|
||||
`
|
||||
eval(t, src, []byte("foo"))
|
||||
}
|
||||
|
||||
func TestByteConversionOfVariable(t *testing.T) {
|
||||
src := `
|
||||
package foo
|
||||
func Main() []byte {
|
||||
a := "fo"
|
||||
a = a + "o"
|
||||
b := []byte(a)
|
||||
return b
|
||||
}
|
||||
`
|
||||
eval(t, src, []byte("foo"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue