Sha256: 1ed93a176c592a48109001a9262a5b87d09189074296101d42f690b2195a05a4

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

$LOAD_PATH.unshift 'lib'

require 'test/unit'
require 'glue/property'

module Mixin
  prop_accessor :date
  ann self, :dummy => [123]
end

class MixedOnly
  include Mixin
  ann.self.dummy! << 5
  ann.self.dummy! << 3 
end

class MixedOnly2
  include Mixin
end

class MixedWithProp
  include Mixin

  prop_accessor :dummy
end

class Pure
  prop_accessor :dummy
end

class Empty
end

class Base
  prop_accessor :date
  ann self, :dummy => [123]
end

class Child1 < Base
  ann.self.dummy!.first << 5
  ann.self.dummy!.first << 3 
end

class Child2 < Base
end

# Tests auto management.
class TC_MixinsTest < ::Test::Unit::TestCase
  def test_the_unmanaged
    assert( Empty.respond_to?( :__props ) == false )
    assert_respond_to( Pure.new, :dummy )
  end

  def test_manage_entities
    assert_respond_to( Pure, :properties )
    assert_respond_to( Pure.new, :dummy )
  end

  def test_managing_mixedonly_classes
    assert_respond_to( MixedOnly.new, :date )
  end

  def test_managing_mixins
    assert_respond_to( Mixin, :properties )
  end

  def test_managing_mixed_classes
    obj = MixedWithProp.new
    assert( obj.respond_to?( :date ) )
    assert( obj.respond_to?( :dummy ) )
  end

  def test_crosspolination
    assert_equal 3, MixedOnly.ann.self[:dummy].size  
# FIXME:
#   assert_equal 1, MixedOnly2.ann.self[:dummy].size  
#   assert_equal 1, Mixin.ann.self[:dummy].size  
=begin
    gmosx: THINK!
    assert_equal 3, Child1.__meta[:dummy].first.size  
    assert_equal 1, Child2.__meta[:dummy].first.size  
    assert_equal 1, Base.__meta[:dummy].first.size  
=end
  end
end

# * Thomas Quas <tquas@yahoo.com>
# * George Moschovitis <gm@navel.gr>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
glue-0.31.0 test/glue/tc_property_mixins.rb
glue-0.25.0 test/glue/tc_property_mixins.rb
glue-0.26.0 test/glue/tc_property_mixins.rb
glue-0.27.0 test/glue/tc_property_mixins.rb
glue-0.28.0 test/glue/tc_property_mixins.rb
glue-0.29.0 test/glue/tc_property_mixins.rb
glue-0.30.0 test/glue/tc_property_mixins.rb