github.com/oweisse/u-root@v0.0.0-20181109060735-d005ad25fef1/cmds/elvish/edit/completion/complete_index_test.go (about)

     1  package completion
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/u-root/u-root/cmds/elvish/parse"
     7  )
     8  
     9  var testIndexee = "a"
    10  
    11  func TestFindIndexComplContext(t *testing.T) {
    12  	testComplContextFinder(t, "findIndexComplContext", findIndexComplContext, []complContextFinderTest{
    13  		{"a[", &indexComplContext{
    14  			complContextCommon{"", quotingForEmptySeed, 2, 2}, testIndexee}},
    15  		{"a[x", &indexComplContext{
    16  			complContextCommon{"x", parse.Bareword, 2, 3}, testIndexee}},
    17  		{"a[x ", &indexComplContext{
    18  			complContextCommon{"", quotingForEmptySeed, 4, 4}, testIndexee}},
    19  		// Not supported when indexee cannot be evaluated statically
    20  		{"(x)[", nil},
    21  		// Multi-layer indexing not supported yet
    22  		{"a[x][", nil},
    23  	})
    24  }