Sha256: f9ccdbd9a576760da1ed9cd90b214d08a2c365a1754e85cf8f6df667e75a399d

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'paramix'
require 'test/unit'

include Paramix

class TC_Paramix_Callback < Test::Unit::TestCase

  # -- fixture ------------------------------

  module M
    include Parametric

    parameterized do |params|

      public :f do
        params[:p]
      end

      attr_accessor params[:p]
    end

    #
    #def self.included(base)
    #  base.class_eval do
    #    attr_accessor mixin_parameters[M][:p]
    #  end
    #  super(base)
    #end
  end

  class C1
    include M[:p => "c1"]
  end

  class C2
    include M[:p => "c2"]
  end

  # -- tests --------------------------------

  def test_class_1
    c = C1.new
    #assert_equal( "c1", c.mixin_params[:p] )
    assert_equal( "c1", c.f )
  end

  def test_class_2
    c = C2.new
    #assert_equal( "c2", c.mixin_params[:p] )
    assert_equal( "c2", c.f )
  end

  def test_callback_class_1
    c = C1.new
    c.c1 = :yes1
    assert_equal(:yes1, c.c1)
  end

  def test_callback_class_2
    c = C2.new
    c.c2 = :yes2
    assert_equal(:yes2, c.c2)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paramix-2.0.0 test/test_paramix_callback.rb