MCPcopy Create free account
hub / github.com/gokcehan/lf / TestExprString

Function TestExprString

eval_test.go:524–563  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

522}
523
524func TestExprString(t *testing.T) {
525 tests := []struct {
526 e expr
527 exp string
528 }{
529 {&setExpr{"hidden!", ""}, "set hidden!"},
530 {&setExpr{"hidden", "true"}, "set hidden true"},
531 {&setLocalExpr{"~", "hidden!", ""}, "setlocal ~ hidden!"},
532 {&setLocalExpr{"~", "hidden", "true"}, "setlocal ~ hidden true"},
533 {&mapExpr{"q", nil}, "map q"},
534 {&mapExpr{"q", &callExpr{"quit", nil, 1}}, "map q quit"},
535 {&nmapExpr{"q", nil}, "nmap q"},
536 {&nmapExpr{"q", &callExpr{"quit", nil, 1}}, "nmap q quit"},
537 {&vmapExpr{"q", nil}, "vmap q"},
538 {&vmapExpr{"q", &callExpr{"quit", nil, 1}}, "vmap q quit"},
539 {&cmapExpr{"q", nil}, "cmap q"},
540 {&cmapExpr{"q", &callExpr{"quit", nil, 1}}, "cmap q quit"},
541 {&cmdExpr{"foo", nil}, "cmd foo"},
542 {&cmdExpr{"foo", &callExpr{"quit", nil, 1}}, "cmd foo quit"},
543 {&callExpr{"quit", nil, 1}, "quit"},
544 {&callExpr{"cd", []string{"~"}, 1}, "cd ~"},
545 {&execExpr{"$", "du -h . | less"}, "${{ du -h . | less }}"},
546 {
547 &execExpr{"$", `
548 mkdir foo
549 cp $fs foo
550 tar -czvf foo.tar.gz foo
551 rm -rf foo
552 `},
553 "${{ mkdir foo ... }}",
554 },
555 {&listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1}, ":{{ toggle; down; }}"},
556 }
557
558 for _, test := range tests {
559 if got := test.e.String(); got != test.exp {
560 t.Errorf("at test '%#v' expected '%s' but got '%s'", test.e, test.exp, got)
561 }
562 }
563}
564
565func TestSplitKeys(t *testing.T) {
566 inps := []struct {

Callers

nothing calls this directly

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected