|
34 | 34 | ",".split(",", 0).should == []
|
35 | 35 | end
|
36 | 36 |
|
| 37 | + it "does not suppress trailing empty fields when a positive limit is given" do |
| 38 | + " 1 2 ".split(" ", 2).should == ["1", "2 "] |
| 39 | + " 1 2 ".split(" ", 3).should == ["1", "2", ""] |
| 40 | + " 1 2 ".split(" ", 4).should == ["1", "2", ""] |
| 41 | + " 1 あ ".split(" ", 2).should == ["1", "あ "] |
| 42 | + " 1 あ ".split(" ", 3).should == ["1", "あ", ""] |
| 43 | + " 1 あ ".split(" ", 4).should == ["1", "あ", ""] |
| 44 | + |
| 45 | + "1,2,".split(',', 2).should == ["1", "2,"] |
| 46 | + "1,2,".split(',', 3).should == ["1", "2", ""] |
| 47 | + "1,2,".split(',', 4).should == ["1", "2", ""] |
| 48 | + "1,あ,".split(',', 2).should == ["1", "あ,"] |
| 49 | + "1,あ,".split(',', 3).should == ["1", "あ", ""] |
| 50 | + "1,あ,".split(',', 4).should == ["1", "あ", ""] |
| 51 | + |
| 52 | + "1 2 ".split(/ /, 2).should == ["1", "2 "] |
| 53 | + "1 2 ".split(/ /, 3).should == ["1", "2", ""] |
| 54 | + "1 2 ".split(/ /, 4).should == ["1", "2", ""] |
| 55 | + "1 あ ".split(/ /, 2).should == ["1", "あ "] |
| 56 | + "1 あ ".split(/ /, 3).should == ["1", "あ", ""] |
| 57 | + "1 あ ".split(/ /, 4).should == ["1", "あ", ""] |
| 58 | + end |
| 59 | + |
37 | 60 | it "returns an array with one entry if limit is 1: the original string" do
|
38 | 61 | "hai".split("hai", 1).should == ["hai"]
|
39 | 62 | "x.y.z".split(".", 1).should == ["x.y.z"]
|
|
0 commit comments