require_relative '../../spec_helper' require_relative 'fixtures/classes' describe "Enumerable#chunk" do before do ScratchPad.record [] end it "returns an Enumerator if called without a block" do chunk = EnumerableSpecs::Numerous.new(1, 2, 3, 1, 2).chunk chunk.should be_an_instance_of(Enumerator) result = chunk.with_index {|elt, i| elt - i }.to_a result.should == [[1, [1, 2, 3]], [-2, [1, 2]]] end it "returns an Enumerator if given a block" do EnumerableSpecs::Numerous.new.chunk {}.should be_an_instance_of(Enumerator) end it "yields the current element and the current chunk to the block" do e = EnumerableSpecs::Numerous.new(1, 2, 3) e.chunk { |x| ScratchPad << x }.to_a ScratchPad.recorded.should == [1, 2, 3] end it "returns elements of the Enumerable in an Array of Arrays, [v, ary], where 'ary' contains the consecutive elements for which the block returned the value 'v'" do e = EnumerableSpecs::Numerous.new(1, 2, 3, 2, 3, 2, 1) result = e.chunk { |x| x < 3 && 1 || 0 }.to_a result.should == [[1, [1, 2]], [0, [3]], [1, [2]], [0, [3]], [1, [2, 1]]] end it "returns elements for which the block returns :_alone in separate Arrays" do e = EnumerableSpecs::Numerous.new(1, 2, 3, 2, 1) result = e.chunk { |x| x < 2 && :_alone }.to_a result.should == [[:_alone, [1]], [false, [2, 3, 2]], [:_alone, [1]]] end it "does not return elements for which the block returns :_separator" do e = EnumerableSpecs::Numerous.new(1, 2, 3, 3, 2, 1) result = e.chunk { |x| x == 2 ? :_separator : 1 }.to_a result.should == [[1, [1]], [1, [3, 3]], [1, [1]]] end it "does not return elements for which the block returns nil" do e = EnumerableSpecs::Numerous.new(1, 2, 3, 2, 1) result = e.chunk { |x| x == 2 ? nil : 1 }.to_a result.should == [[1, [1]], [1, [3]], [1, [1]]] end it "raises a RuntimeError if the block returns a Symbol starting with an underscore other than :_alone or :_separator" do e = EnumerableSpecs::Numerous.new(1, 2, 3, 2, 1) -> { e.chunk { |x| :_arbitrary }.to_a }.should raise_error(RuntimeError) end it "does not accept arguments" do e = EnumerableSpecs::Numerous.new(1, 2, 3) -> { e.chunk(1) {} }.should raise_error(ArgumentError) end it 'returned Enumerator size returns nil' do e = EnumerableSpecs::NumerousWithSize.new(1, 2, 3, 2, 1) enum = e.chunk { |x| true } enum.size.should == nil end end >
path: root/ext/socket/ifaddr.c
AgeCommit message (Expand)Author
2021-08-20undefine alloc functions for C extensionsMike Dalessio
2020-12-22Removed rb_cData entityNobuyoshi Nakada
2017-12-22ifaddr.c: get_ifaddrsnobu
2017-12-04ifaddr.c: fix memsizenobu
2017-12-03ifaddr.c: unused membernobu
2017-11-07ext/socket/ifaddr.c: [DOC] fix typostomar
2017-08-31Add Socket::Ifaddr.vhid on supported platforms [Feature #13803]naruse
2015-12-09ext/socket/ifaddr.c: remove empty ifaddr_marknormal
2015-12-09* ext/**/*.c (*_memsize): same as r52986 for extensions.ko1
2015-05-16ifaddr.c: wrapper object before allocnobu
2014-05-27* ext/socket/ifaddr.c (ifaddr_inspect_flags): support IFF_SIMPLEX.naruse
2014-05-11* ext/socket/ifaddr.c (IS_IFADDRS): Unused macro removed.akr
2013-10-02* ext/socket/ifaddr.c (rsock_getifaddrs): fix possible memory leak.mame
2013-05-17* ext/socket/ifaddr.c: Use unsigned LONG_LONG to represent flagsakr
2013-05-17Enable the document for Socket::Ifaddr#ifindex.akr
2013-05-14socket: fix build error and warnings on mingwnobu
2013-05-14Update doc.akr
2013-05-11* ext/socket: New method, Socket.getifaddrs, implemented.akr