Sha256: 3324d05387a7598652f7704b2b3c448863acd4e7c842791a4eda0650d3bc8e83

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/more/openobject.rb
#
# Extracted Tue Jun 06 09:30:19 EDT 2006
# Unit Tools Reap Test Extractor
#

require 'facets/more/openobject.rb'


  require 'test/unit'

  class TC01 < Test::Unit::TestCase

    def test_01_001
      f0 = OpenObject.new
      f0[:a] = 1
      assert_equal( [1], f0.to_a )
      assert_equal( {:a=>1}, f0.to_h )
    end

    def test_01_002
      f0 = OpenObject.new( {:a=>1} )
      f0[:b] = 2
      assert_equal( {:a=>1,:b=>2}, f0.to_h )
    end
  end

  class TC02 < Test::Unit::TestCase

    def test_02_001
      f0 = OpenObject.new( :f0=>"f0" )
      h0 = { :h0=>"h0" }
      assert_equal( OpenObject.new( :f0=>"f0", :h0=>"h0" ), f0.__merge__( h0 ) )
      assert_equal( {:f0=>"f0", :h0=>"h0"}, h0.merge( f0 ) )
    end

    def test_02_002
      f1 = OpenObject.new( :f1=>"f1" )
      h1 = { :h1=>"h1" }
      f1.__update__( h1 )
      h1.update( f1 )
      assert_equal( OpenObject.new( :f1=>"f1", :h1=>"h1" ), f1 )
      assert_equal( {:f1=>"f1", :h1=>"h1"}, h1 )
    end

  end

  class TC03 < Test::Unit::TestCase

    def test_03_001
      fo = OpenObject.new
      99.times{ |i| fo.__send__( "n#{i}=", 1 ) }
      99.times{ |i|
        assert_equal( 1, fo.__send__( "n#{i}" ) )
      }
    end

  end

  class TC04 < Test::Unit::TestCase

    def test_04_001
      p = lambda { |x|
        x.word = "Hello"
      }
      o = p.to_openobject
      assert_equal( "Hello", o.word )
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.4.1 test/lib/facets/more/test_openobject.rb