Sha256: 9305b9a0079c5057df6c9c1784fdcca139dc3780e39053350dc6618b3e94e4ef

Contents?: true

Size: 1.57 KB

Versions: 83

Compression:

Stored size: 1.57 KB

Contents

module ArraySpecs
  not_compliant_on :rubinius do
    def self.max_32bit_size
      2**32/4
    end

    def self.max_64bit_size
      2**64/8
    end
  end

  deviates_on :rubinius do
    def self.max_32bit_size
      2**30-1
    end

    def self.max_64bit_size
      2**62-1
    end
  end

  def self.frozen_array
    frozen_array = [1,2,3]
    frozen_array.freeze
    frozen_array
  end

  def self.recursive_array
    a = [1, 'two', 3.0]
    5.times { a << a }
    a
  end

  def self.head_recursive_array
    a =  []
    5.times { a << a }
    a << 1 << 'two' << 3.0
    a
  end

  def self.empty_recursive_array
    a = []
    a << a
    a
  end

  class MyArray < Array; end

  class Sexp < Array
    def initialize(*args)
      super(args)
    end
  end

  # TODO: replace specs that use this with #should_not_receive(:to_ary)
  # expectations on regular objects (e.g. Array instances).
  class ToAryArray < Array
    def to_ary() ["to_ary", "was", "called!"] end
  end

  class MyRange < Range; end

  class AssocKey
    def ==(other); other == 'it'; end
  end

  class D
    def <=>(obj)
      return 4 <=> obj unless obj.class == D
      0
    end
  end

  class SubArray < Array
    def initialize(*args)
      ScratchPad.record args
    end
  end

  class ArrayConvertable
    attr_accessor :called
    def initialize(*values, &block)
      @values = values;
    end
    
    def to_a
      self.called = :to_a
      @values
    end
    
    def to_ary
      self.called = :to_ary
      @values
    end
  end

  class ArrayNotReallyConvertable
    def to_ary
      raise "Oups"
    end
  end

end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/array/fixtures/classes.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/array/fixtures/classes.rb