Sha256: caa4c94deecfa00918738a7f2ca731b7b97ec4d6d53ace444425da04ec3f2e04

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require "test/unit"

require "glue/logger"; $log = Logger.new(STDERR) unless $log

require "glue/property"

module Test # :nodoc: all

class Msg
	include Og::Unmanageable
	
	prop Fixnum, :owner_oid
	prop_accessor :val1, :val2, :val3, Fixnum, :sql => "smallint"
	prop_accessor :title, :body, String
	prop_accessor :test, String, :sql => "char(10) NOT NULL"
	prop_accessor :count, Fixnum
	prop_accessor :create_time, Time	

	# a marshaled property
	prop_accessor Array, :options
	
	def initialize
		@create_time = Time.now
		@options = []
	end

end

class SubMsg < Msg
	# to avoid conflicts with tc_og.rb
	include Og::Unmanageable
	
	inherit_meta(superclass)
	# duplicate definition with different type!
	prop_accessor :count, Float
end

class TC_N_Properties < Test::Unit::TestCase

	def setup
		@msg1 = Msg.new
	end

	def teardown
		@msg1 = nil
	end

	def test_props
		
		# bug: props for subclasses.

		assert(SubMsg.__props)
		assert_equal(Msg.__props.size(), SubMsg.__props.size())

		# bug: duplicate definition 			
		
		assert_equal(Float, SubMsg.__props.find { |p| :count == p.symbol }.klass)

		# dont force conversion
		
		@msg1.count = 2.4
		assert_equal(Float, @msg1.count.class)

		# force conversion
		
		@msg1.__force_count(2.4)
		assert_equal(Fixnum, @msg1.count.class)		
	end
	
end

end # module

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.5.0 test/glue/tc_properties.rb
nitro-0.6.0 test/glue/tc_properties.rb