Skip to content
Myr

Disallow incorrect wrapping range expression for --nth

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 9d6637c · Browse files · 2 files+13 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−1 removed

  • other:+13 added−1 removed

2 files+13 added−1 removed

modified:src/tokenizer_test.go+12 added
38 unmodified lines
39 if r.begin != 3 || r.end != 3 {40 t.Errorf("%v", r)41 }42 }43 {44 i := "1..3..5"45 if r, ok := ParseRange(&i); ok {46 t.Errorf("%v", r)47 }48 }49 {50 i := "-3..3"51 if r, ok := ParseRange(&i); ok {52 t.Errorf("%v", r)53 }54 }55}5657func TestTokenize(t *testing.T) {58 // AWK-style
67 unmodified lines
modified:src/tokenizer.go+1 added-1 removed
71 unmodified lines
72 return Range{}, false73 }74 begin, err1 := strconv.Atoi(ns[0])75 end, err2 := strconv.Atoi(ns[1])76 if err1 != nil || err2 != nil || begin == 0 || end == 0 {76 if err1 != nil || err2 != nil || begin == 0 || end == 0 || begin < 0 && end > 0 {77 return Range{}, false78 }79 return newRange(begin, end), true80 }
173 unmodified lines