Sha256: 29af5957ed52bb5c774e177e30e7c332eeb35bc6146e6b19fce8968de9732b04

Contents?: true

Size: 803 Bytes

Versions: 11

Compression:

Stored size: 803 Bytes

Contents

require 'psych/helper'

module Psych
  class TestSerializeSubclasses < TestCase
    class SomeObject
      def initialize one, two
        @one = one
        @two = two
      end

      def == other
        @one == other.instance_eval { @one } &&
          @two == other.instance_eval { @two }
      end
    end

    def test_some_object
      so = SomeObject.new('foo', [1,2,3])
      assert_equal so, Psych.load(Psych.dump(so))
    end

    class StructSubclass < Struct.new(:foo)
      def initialize foo, bar
        super(foo)
        @bar = bar
      end

      def == other
        super(other) && @bar == other.instance_eval{ @bar }
      end
    end

    def test_struct_subclass
      so = StructSubclass.new('foo', [1,2,3])
      assert_equal so, Psych.load(Psych.dump(so))
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
psych-1.3.4 test/psych/test_serialize_subclasses.rb
psych-1.3.3 test/psych/test_serialize_subclasses.rb
psych-1.3.2 test/psych/test_serialize_subclasses.rb
psych-1.3.1 test/psych/test_serialize_subclasses.rb
psych-1.3.0 test/psych/test_serialize_subclasses.rb
psych-1.2.2 test/psych/test_serialize_subclasses.rb
psych-1.2.2.rc1 test/psych/test_serialize_subclasses.rb
psych-1.2.1 test/psych/test_serialize_subclasses.rb
psych-1.2.0 test/psych/test_serialize_subclasses.rb
psych-1.1.1 test/psych/test_serialize_subclasses.rb
psych-1.1.0 test/psych/test_serialize_subclasses.rb