Sha256: 665a1a11b18fd252b4bbc9d71a9abad645c62952aedccd484574f1d0619b73c5

Contents?: true

Size: 1.62 KB

Versions: 6

Compression:

Stored size: 1.62 KB

Contents

# * Thomas Quas  <tquas@yahoo.com>
# * George Moschovitis  <gm@navel.gr>
# $Id: tc_property_mixins.rb 1 2005-04-11 11:04:30Z 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

6 entries across 6 versions & 1 rubygems

Version Path
glue-0.16.0 test/glue/tc_property_mixins.rb
glue-0.17.0 test/glue/tc_property_mixins.rb
glue-0.18.0 test/glue/tc_property_mixins.rb
glue-0.18.1 test/glue/tc_property_mixins.rb
glue-0.19.0 test/glue/tc_property_mixins.rb
glue-0.20.0 test/glue/tc_property_mixins.rb