Sha256: 612b6690a298750a4c9e46d1c5162c8e2bc4abffc3debb1c4e8995ee983d9ea6

Contents?: true

Size: 1.6 KB

Versions: 9

Compression:

Stored size: 1.6 KB

Contents

#! /usr/bin/env ruby
# vim:sw=2:ai

#--
# Thomas Quas  <tquas@yahoo.com>
# George Moschovitis  <gm@navel.gr>
# $Id$
#++

$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

9 entries across 9 versions & 2 rubygems

Version Path
glue-0.15.0 test/glue/tc_property_mixins.rb
glue-0.13.0 test/glue/tc_property_mixins.rb
glue-0.14.0 test/glue/tc_property_mixins.rb
nitro-0.10.0 test/glue/tc_property_mixins.rb
nitro-0.11.0 test/glue/tc_property_mixins.rb
nitro-0.12.0 test/glue/tc_property_mixins.rb
nitro-0.8.0 test/glue/tc_property_mixins.rb
nitro-0.9.3 test/glue/tc_property_mixins.rb
nitro-0.9.5 test/glue/tc_property_mixins.rb