Sha256: 1bcdd32036978242d0c25a298cb8e3a9725cfde7fda21682d81dc3f4cb11c7e4

Contents?: true

Size: 1.16 KB

Versions: 83

Compression:

Stored size: 1.16 KB

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/shared/to_s'

describe "Hash#inspect" do
  it_behaves_like :to_s, :inspect
 
  # FIXME: When http://redmine.ruby-lang.org/issues/show/1533 is fixed, this
  # block can be removed, as the behaviour will then be shared with to_s
  # completely. 
  it "handles recursive hashes" do
    x = new_hash
    x[0] = x
    x.inspect.should == '{0=>{...}}'

    x = new_hash
    x[x] = 0
    x.inspect.should == '{{...}=>0}'

    x = new_hash
    x[x] = x
    x.inspect.should == '{{...}=>{...}}'

    x = new_hash
    y = new_hash
    x[0] = y
    y[1] = x
    x.inspect.should == "{0=>{1=>{...}}}"
    y.inspect.should == "{1=>{0=>{...}}}"

    x = new_hash
    y = new_hash
    x[y] = 0
    y[x] = 1
    x.inspect.should == "{{{...}=>1}=>0}"
    y.inspect.should == "{{{...}=>0}=>1}"
    
    x = new_hash
    y = new_hash
    x[y] = x
    y[x] = y
    x.inspect.should == "{{{...}=>{...}}=>{...}}"
    y.inspect.should == "{{{...}=>{...}}=>{...}}"
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-2.0.2 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.rc2 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.rc1 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta11 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta10 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta9 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta8 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta7 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta6 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta4 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta3 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-1.5.5 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta2 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-2.0.0.beta1 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-1.5.4 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-1.5.3 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-1.5.2 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-1.5.1 spec/framework_spec/app/spec/core/hash/inspect_spec.rb
rhodes-1.5.0 spec/framework_spec/app/spec/core/hash/inspect_spec.rb