Sha256: 5d15fdc6063edf05519fa14fe5536d496af1c9261269f9f8d77a9105af251b72

Contents?: true

Size: 789 Bytes

Versions: 60

Compression:

Stored size: 789 Bytes

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

# Array#nitems was removed from Ruby 1.9.
ruby_version_is '' ... '1.9' do
  describe "Array#nitems" do
    it "returns the number of non-nil elements" do
      [nil].nitems.should == 0
      [].nitems.should == 0
      [1, 2, 3, nil].nitems.should == 3
      [1, 2, 3].nitems.should == 3
      [1, nil, 2, 3, nil, nil, 4].nitems.should == 4
      [1, nil, 2, false, 3, nil, nil, 4].nitems.should == 5
    end

    it "properly handles recursive arrays" do
      empty = ArraySpecs.empty_recursive_array
      empty.nitems.should == 1

      array = ArraySpecs.recursive_array
      array.nitems.should == 8

      [nil, empty, array].nitems.should == 2
    end
  end
end

Version data entries

60 entries across 60 versions & 3 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/array/nitems_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/array/nitems_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/array/nitems_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/array/nitems_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/array/nitems_spec.rb
opal-0.4.4 spec/rubyspec/core/array/ntimes_spec.rb
opal-0.4.3 spec/rubyspec/core/array/ntimes_spec.rb
opal-0.4.2 spec/rubyspec/core/array/ntimes_spec.rb