Sha256: 6a355e75b470bb57e5e54ed2285e950ce9fb52f079357d6475bbd332d694a4b3

Contents?: true

Size: 705 Bytes

Versions: 4

Compression:

Stored size: 705 Bytes

Contents

require 'facets/kernel/hierarchical_send'

test_case Object do

  setup do
    m = Module.new do
      attr :a
      def preinitialize
        @a = 10
      end
    end

    @x = Class.new do
      include m
      attr :b
      def preinitialize
        @b = 20
      end
      def initialize
        hierarchical_send(:preinitialize)
      end
    end

    @y = Class.new(@x) do
      def initialize
        @a = "not 10"
        @b = "not 20"
        super
      end
    end
  end

  method :hierarchical_send do
    test do
      x = @x.new
      x.a.assert == 10
      x.b.assert == 20
    end

    test 'subclass' do
      y = @y.new
      y.a.assert == 10
      y.b.assert == 20
    end
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 test/core/kernel/test_hierarchical_send.rb
facets-3.1.0 test/core/kernel/test_hierarchical_send.rb
facets-3.0.0 test/core/kernel/test_hierarchical_send.rb
facets-2.9.3 test/core/kernel/test_hierarchical_send.rb