@@ -4,87 +4,87 @@ import "testing"
44
55func TestSplitForCompletion (t * testing.T ) {
66 tests := []struct {
7- name string
8- input string
9- format Format
10- wantWord string
11- wantPrefix string
12- wantState LexerState
7+ name string
8+ input string
9+ format Format
10+ wantWord string
11+ wantPrefix string
12+ wantState LexerState
1313 wantRedirect bool
14- wantWords []string
14+ wantWords []string
1515 }{
1616 {
17- name : "simple word" ,
18- input : "echo hel" ,
19- format : BashFormat (),
20- wantWord : "hel" ,
17+ name : "simple word" ,
18+ input : "echo hel" ,
19+ format : BashFormat (),
20+ wantWord : "hel" ,
2121 wantPrefix : "" ,
22- wantState : IN_WORD_STATE ,
23- wantWords : []string {"echo" , "hel" },
22+ wantState : IN_WORD_STATE ,
23+ wantWords : []string {"echo" , "hel" },
2424 },
2525 {
26- name : "inside double quotes" ,
27- input : `echo "hel` ,
28- format : BashFormat (),
29- wantWord : "hel" ,
26+ name : "inside double quotes" ,
27+ input : `echo "hel` ,
28+ format : BashFormat (),
29+ wantWord : "hel" ,
3030 wantPrefix : "" ,
31- wantState : QUOTING_ESCAPING_STATE ,
32- wantWords : []string {"echo" , "hel" },
31+ wantState : QUOTING_ESCAPING_STATE ,
32+ wantWords : []string {"echo" , "hel" },
3333 },
3434 {
35- name : "inside single quotes" ,
36- input : "echo 'hel" ,
37- format : BashFormat (),
38- wantWord : "hel" ,
35+ name : "inside single quotes" ,
36+ input : "echo 'hel" ,
37+ format : BashFormat (),
38+ wantWord : "hel" ,
3939 wantPrefix : "" ,
40- wantState : QUOTING_STATE ,
41- wantWords : []string {"echo" , "hel" },
40+ wantState : QUOTING_STATE ,
41+ wantWords : []string {"echo" , "hel" },
4242 },
4343 {
44- name : "pipeline" ,
45- input : "echo foo | grep bar" ,
46- format : BashFormat (),
47- wantWord : "bar" ,
44+ name : "pipeline" ,
45+ input : "echo foo | grep bar" ,
46+ format : BashFormat (),
47+ wantWord : "bar" ,
4848 wantPrefix : "" ,
49- wantState : IN_WORD_STATE ,
50- wantWords : []string {"grep" , "bar" },
49+ wantState : IN_WORD_STATE ,
50+ wantWords : []string {"grep" , "bar" },
5151 },
5252 {
53- name : "redirect target" ,
54- input : "echo foo > bar" ,
55- format : BashFormat (),
56- wantWord : "bar" ,
57- wantPrefix : "" ,
58- wantState : IN_WORD_STATE ,
53+ name : "redirect target" ,
54+ input : "echo foo > bar" ,
55+ format : BashFormat (),
56+ wantWord : "bar" ,
57+ wantPrefix : "" ,
58+ wantState : IN_WORD_STATE ,
5959 wantRedirect : true ,
60- wantWords : []string {"echo" , "foo" },
60+ wantWords : []string {"echo" , "foo" },
6161 },
6262 {
63- name : "wordbreak prefix with equals" ,
64- input : "echo foo=bar" ,
65- format : BashFormat (),
66- wantWord : "foo=bar" ,
63+ name : "wordbreak prefix with equals" ,
64+ input : "echo foo=bar" ,
65+ format : BashFormat (),
66+ wantWord : "foo=bar" ,
6767 wantPrefix : "foo=" ,
68- wantState : IN_WORD_STATE ,
69- wantWords : []string {"echo" , "foo=bar" },
68+ wantState : IN_WORD_STATE ,
69+ wantWords : []string {"echo" , "foo=bar" },
7070 },
7171 {
72- name : "empty input" ,
73- input : "" ,
74- format : BashFormat (),
75- wantWord : "" ,
72+ name : "empty input" ,
73+ input : "" ,
74+ format : BashFormat (),
75+ wantWord : "" ,
7676 wantPrefix : "" ,
77- wantState : START_STATE ,
78- wantWords : []string {"" },
77+ wantState : START_STATE ,
78+ wantWords : []string {"" },
7979 },
8080 {
81- name : "escape at end" ,
82- input : `echo foo\` ,
83- format : BashFormat (),
84- wantWord : "foo" ,
81+ name : "escape at end" ,
82+ input : `echo foo\` ,
83+ format : BashFormat (),
84+ wantWord : "foo" ,
8585 wantPrefix : "" ,
86- wantState : ESCAPING_STATE ,
87- wantWords : []string {"echo" , "foo" },
86+ wantState : ESCAPING_STATE ,
87+ wantWords : []string {"echo" , "foo" },
8888 },
8989 }
9090
0 commit comments