-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathcursor_test.go
More file actions
51 lines (38 loc) · 735 Bytes
/
Copy pathcursor_test.go
File metadata and controls
51 lines (38 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package wsl
import (
"go/ast"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSavestate(t *testing.T) {
t.Parallel()
cursor := NewCursor([]ast.Stmt{
&ast.AssignStmt{},
&ast.AssignStmt{},
&ast.AssignStmt{},
&ast.AssignStmt{},
&ast.AssignStmt{},
&ast.AssignStmt{},
&ast.AssignStmt{},
})
reset := cursor.Save()
cursor.Next()
cursor.Next()
func() {
reset := cursor.Save()
defer reset()
cursor.Next()
cursor.Next()
func() {
reset := cursor.Save()
defer reset()
cursor.Next()
cursor.Next()
assert.Equal(t, 5, cursor.currentIdx)
}()
assert.Equal(t, 3, cursor.currentIdx)
}()
assert.Equal(t, 1, cursor.currentIdx)
reset()
assert.Equal(t, -1, cursor.currentIdx)
}