Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 38 lines (30 sloc) 1.212 kB
957c2c9 @brixen Standardize require lines.
brixen authored
1 require File.expand_path('../../../spec_helper', __FILE__)
2 require File.expand_path('../fixtures/classes', __FILE__)
3 require File.expand_path('../shared/enumeratorize', __FILE__)
6c1c34a @brixen Ask not what RubySpec can do for you, but what you can do for RubySpec.
brixen authored
4
4d7ad6c @brixen Update some Array specs according to [ruby-core:23633].
brixen authored
5 # Modifying a collection while the contents are being iterated
6 # gives undefined behavior. See
7 # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23633
8
6c1c34a @brixen Ask not what RubySpec can do for you, but what you can do for RubySpec.
brixen authored
9 describe "Array#reverse_each" do
4d7ad6c @brixen Update some Array specs according to [ruby-core:23633].
brixen authored
10 before :each do
11 ScratchPad.record []
12 end
13
6c1c34a @brixen Ask not what RubySpec can do for you, but what you can do for RubySpec.
brixen authored
14 it "traverses array in reverse order and pass each element to block" do
4d7ad6c @brixen Update some Array specs according to [ruby-core:23633].
brixen authored
15 [1, 3, 4, 6].reverse_each { |i| ScratchPad << i }
16 ScratchPad.recorded.should == [6, 4, 3, 1]
6c1c34a @brixen Ask not what RubySpec can do for you, but what you can do for RubySpec.
brixen authored
17 end
18
4d7ad6c @brixen Update some Array specs according to [ruby-core:23633].
brixen authored
19 it "returns self" do
20 a = [:a, :b, :c]
21 a.reverse_each { |x| }.should equal(a)
22 end
23
24 it "yields only the top level element of an empty recursive arrays" do
8402c9f @vvs And yet more tests for recursive arrays.
vvs authored
25 empty = ArraySpecs.empty_recursive_array
4d7ad6c @brixen Update some Array specs according to [ruby-core:23633].
brixen authored
26 empty.reverse_each { |i| ScratchPad << i }
27 ScratchPad.recorded.should == [empty]
28 end
8402c9f @vvs And yet more tests for recursive arrays.
vvs authored
29
4d7ad6c @brixen Update some Array specs according to [ruby-core:23633].
brixen authored
30 it "yields only the top level element of a recursive array" do
8402c9f @vvs And yet more tests for recursive arrays.
vvs authored
31 array = ArraySpecs.recursive_array
4d7ad6c @brixen Update some Array specs according to [ruby-core:23633].
brixen authored
32 array.reverse_each { |i| ScratchPad << i }
33 ScratchPad.recorded.should == [array, array, array, array, array, 3.0, 'two', 1]
8402c9f @vvs And yet more tests for recursive arrays.
vvs authored
34 end
35
8fb6ab7 @calavera Array specs refactor to use common specs to check behavior when no bl…
calavera authored
36 it_behaves_like :enumeratorize, :reverse_each
6c1c34a @brixen Ask not what RubySpec can do for you, but what you can do for RubySpec.
brixen authored
37 end
Something went wrong with that request. Please try again.