forked from x-motemen/gore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession_test.go
56 lines (45 loc) · 821 Bytes
/
session_test.go
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
52
53
54
55
56
package main
import (
"testing"
)
func TestRun_import(t *testing.T) {
s, err := NewSession()
noError(t, err)
codes := []string{
":import encoding/json",
"b, err := json.Marshal(nil)",
"string(b)",
}
for _, code := range codes {
err := s.Eval(code)
noError(t, err)
}
}
func TestRun_QuickFix_evaluated_but_not_used(t *testing.T) {
s, err := NewSession()
noError(t, err)
codes := []string{
`[]byte("")`,
`make([]int, 0)`,
`1+1`,
`func() {}`,
`1`,
}
for _, code := range codes {
err := s.Eval(code)
noError(t, err)
}
}
func TestRun_FixImports(t *testing.T) {
s, err := NewSession()
noError(t, err)
autoimport := true
flagAutoImport = &autoimport
codes := []string{
`filepath.Join("a", "b")`,
}
for _, code := range codes {
err := s.Eval(code)
noError(t, err)
}
}