Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
describe "Array#[]=" do it "sets the value of the element at index" do a = [1, 2, 3, 4] a[2] = 5 a[-1] = 6 a[5] = 3 a.should == [1, 2, 5, 6, nil, 3] a = [] a[4] = "e" a.should == [nil, nil, nil, nil, "e"] a[3] = "d" a.should == [nil, nil, nil, "d", "e"] a[0] = "a" a.should == ["a", nil, nil, "d", "e"] a[-3] = "C" a.should == ["a", nil, "C", "d", "e"] a[-1] = "E" a.should == ["a", nil, "C", "d", "E"] a[-5] = "A" a.should == ["A", nil, "C", "d", "E"] a[5] = "f" a.should == ["A", nil, "C", "d", "E", "f"] a[1] = [] a.should == ["A", [], "C", "d", "E", "f"] a[-1] = nil a.should == ["A", [], "C", "d", "E", nil] end it "removes the section defined by start, length when set to nil" do a = ['a', 'b', 'c', 'd', 'e'] a[1, 3] = nil a.should == ["a", "e"] end it "sets the section defined by start, length to other" do a = [1, 2, 3, 4, 5, 6] a[0, 1] = 2 a[3, 2] = ['a', 'b', 'c', 'd'] a.should == [2, 2, 3, "a", "b", "c", "d", 6] end it "removes the section defined by range when set to nil" do a = [1, 2, 3, 4, 5] a[0..1] = nil a.should == [3, 4, 5] end it "sets the section defined by range to other" do a = [6, 5, 4, 3, 2, 1] a[1...2] = 9 a[3..6] = [6, 6, 6] a.should == [6, 9, 4, 6, 6, 6] end # ... end
Pasted April 21, 200810:53PM EDT
Embed