Sha256: 4d7ac294f4b04a40ec2ac519b636c88cef4e35f7051c6d20115e2c74c85ddda2

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

# * Thomas Quas  <tquas@yahoo.com>
# * George Moschovitis  <gm@navel.gr>
# $Id: tc_property_mixins.rb 182 2005-07-22 10:07:50Z gmosx $

$LOAD_PATH.unshift 'lib'

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

module Mixin
  prop_accessor :date
  meta :dummy, [123]
end

class MixedOnly
  include Mixin
  __meta[:dummy] << 5
  __meta[: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
  meta :dummy, [123]
end

class Child1 < Base
  __meta[:dummy].first << 5
  __meta[: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, :__props )
    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, :__props )
  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.__meta[:dummy].size  
    assert_equal 1, MixedOnly2.__meta[:dummy].size  
    assert_equal 1, Mixin.__meta[: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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glue-0.21.0 test/glue/tc_property_mixins.rb
glue-0.21.2 test/glue/tc_property_mixins.rb
glue-0.22.0 test/glue/tc_property_mixins.rb
glue-0.23.0 test/glue/tc_property_mixins.rb