Sha256: 7662380ca8beffa61e5379afdb111c4b64acb63fe43caaed6f60f1292ceace47

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/core/hash/to_ostruct_recurse.rb
#
# Extracted Fri Feb 16 02:00:36 EST 2007
# Project.rb Test Extraction
#

require 'facets/core/hash/to_ostruct_recurse.rb'


  require 'test/unit'

  class TCHash < Test::Unit::TestCase

    def test_to_ostruct_recurse
      a = { :a => 1, :b => 2, :c => { :x => 4 } }
      ao = a.to_ostruct_recurse
      assert_equal(  a[:a], ao.a )
      assert_equal(  a[:b], ao.b )
      assert_equal(  a[:c][:x], ao.c.x )
    end

    def test_to_ostruct_recurse_with_recursion
      a = {}
      a[:a] = a
      ao = a.to_ostruct_recurse
      assert_equal( ao, ao.a )
    end

    def test_to_ostruct_advanced
      h = { 'a' => { 'b' => 1 } }
      o = h.to_ostruct_recurse( { h['a'] => h['a'] } )
      assert_equal( 1, o.a['b'] )
      assert( Hash === o.a )
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.8.49 test/lib/facets/core/hash/test_to_ostruct_recurse.rb