Sha256: cbea2d3ce7e827b12fcea662ed1f362aadb23fe21503bfd1e9fd8738746a0206

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

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

require 'facets/core/kernel/to_data.rb'


  require 'test/unit'

  class TestToData < Test::Unit::TestCase

    class X
      attr_accessor :a, :b, :c
      def initialize(a, b, c)
        @a, @b, @c = a, b, c
      end
      def ==( other )
        return false if @a != other.a
        return false if @b != other.b
        return false if @c != other.c
        true
      end
    end

    def test_001
      x = X.new( 1, 2, 3 )
      assert_equal( { :a=>1, :b=>2, :c=>3 }, x.to_data )
    end

    def test_002
      x = X.new( 1, 2, [:a,:b] )
      assert_equal( { :a=>1, :b=>2, :c=>[:a,:b] }, x.to_data )
    end

    def test_003
      x = X.new( 1, 2, 3 )
      d = x.to_data
      x.a = 3
      assert_equal( 3, x.a )
      x.from_data(d)
      assert_equal( 1, x.a )
    end

    def test_004
      x = X.new( 1, 2, 3 )
      d = x.to_data
      y = d.to_object
      assert_equal( x, y )
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.8.49 test/lib/facets/core/kernel/test_to_data.rb