mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 01:41:48 +00:00
compiler: support for loops with no init/post condition
Make it possible to use `for` loop with a single condition.
This commit is contained in:
parent
01e16e68ad
commit
328267ca6f
2 changed files with 33 additions and 2 deletions
|
@ -370,3 +370,30 @@ func TestForLoopBigIter(t *testing.T) {
|
|||
`
|
||||
eval(t, src, big.NewInt(99999))
|
||||
}
|
||||
|
||||
func TestForLoopNoInit(t *testing.T) {
|
||||
src := `
|
||||
package foo
|
||||
func Main() int {
|
||||
i := 0
|
||||
for ; i < 10; i++ {
|
||||
}
|
||||
return i
|
||||
}
|
||||
`
|
||||
eval(t, src, big.NewInt(10))
|
||||
}
|
||||
|
||||
func TestForLoopNoPost(t *testing.T) {
|
||||
src := `
|
||||
package foo
|
||||
func Main() int {
|
||||
i := 0
|
||||
for i < 10 {
|
||||
i++
|
||||
}
|
||||
return i
|
||||
}
|
||||
`
|
||||
eval(t, src, big.NewInt(10))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue