Sha256: a9a179d776437173ad2787fc51b6eee1f5a61aff89a16b5f3ef590a65f5a834a

Contents?: true

Size: 1.63 KB

Versions: 10

Compression:

Stored size: 1.63 KB

Contents

  #  _____         _
  # |_   _|__  ___| |_
  #   | |/ _ \/ __| __|
  #   | |  __/\__ \ |
  #   |_|\___||___/\__|
  #
  # for lib/facets/kernel/populate.rb
  #
  # Extracted Mon Sep 03 16:23:07 -0700 2007
  # w/ Test Extraction Ratchet
  #

 require 'facets/kernel/populate.rb'



  require 'test/unit'

  class TestKernelPopulate < Test::Unit::TestCase

#     def test_assign_from
#       o = Object.new
#       o.instance_eval{ @z=0; @a=1; @b=2 } #; @@a=3 }
#       assign_from( o, "z", "@a", "@b" ) #, "@@a" )
#       assert_equal( 1, @a )
#       assert_equal( 2, @b )
#       #assert_equal( 3, @@a )
#     end

    Customer = Struct.new( "Customer", :name, :address, :zip )

    def test_set_from
      bob = Customer.new("Bob Sawyer", "123 Maple, Anytown NC", 12345)
      joe = Customer.new("Joe Pitare")
      joe.set_from(bob, :address, :zip)
      assert_equal("Joe Pitare", joe.name)
      assert_equal("123 Maple, Anytown NC", joe.address)
      assert_equal(12345, joe.zip)
    end

    #Customer = Struct.new( "Customer", :name, :address, :zip )

    def test_hash
      bob = Customer.new()
      x = { :name => "Bob Sawyer", :address => "123 Maple, Anytown NC", :zip => 12345 }
      bob.set_with(x)
      assert_equal(x[:name], bob.name)
      assert_equal(x[:address], bob.address)
      assert_equal(x[:zip], bob.zip)
    end

    def test_block
      bob = Customer.new()
      x = lambda {|s| s.name = "Bob Sawyer"; s.address = "123 Maple, Anytown NC"; s.zip = 12345 }
      bob.set_with(&x)
      assert_equal("Bob Sawyer", bob.name)
      assert_equal("123 Maple, Anytown NC", bob.address)
      assert_equal(12345, bob.zip)
    end

  end



Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.0.0 test/unit/kernel/test_populate.rb
facets-2.0.1 test/unit/kernel/test_populate.rb
facets-2.0.2 test/unit/kernel/test_populate.rb
facets-2.1.2 test/unit/kernel/test_populate.rb
facets-2.0.5 test/unit/kernel/test_populate.rb
facets-2.0.3 test/unit/kernel/test_populate.rb
facets-2.0.4 test/unit/kernel/test_populate.rb
facets-2.1.0 test/unit/kernel/test_populate.rb
facets-2.1.1 test/unit/kernel/test_populate.rb
facets-2.1.3 test/unit/kernel/test_populate.rb