Sha256: 5dcff67de1fd54552ccfe8c61f470f987b39d982dd1d31eaaf33cfdc4c595477

Contents?: true

Size: 1002 Bytes

Versions: 2

Compression:

Stored size: 1002 Bytes

Contents

require 'anise/annotation'
require 'anise/attribute'

include Anise::Attribute

class Test_Attribute_Toplevel < Test::Unit::TestCase
  class X
    attr :q
    attr :a, :x => 1
  end

  def test_attr_a
    assert_equal( {:x=>1}, X.ann(:a) )
  end
end

class Test_Attribute_Toplevel_Using_Attr < Test::Unit::TestCase
  class A
    attr :x, :cast=>"to_s"
  end

  def test_01
    assert_equal( "to_s", A.ann(:x,:cast) )
  end
end

class Test_Attribute_Toplevel_Using_Attr_Accessor < Test::Unit::TestCase
  class A
    attr_accessor :x, :cast=>"to_s"
  end

  def test_01
    a = A.new
    assert_equal( [:x], A.instance_attributes )
  end
end


=begin
require 'annotable/attributes'
require 'test/unit'

include Anise::Attributes

$self = self

attr :b, :y => 1

class Test_Attribute_Toplevel < Test::Unit::TestCase

  attr :q

  attr :a, :x => 1

  def test_attr_a
    assert_equal( {:x=>1}, self.class.ann(:a) )
  end

  def test_attr_b
    assert_equal( {:y=>1}, $self.class.ann(:b) )
  end

end
=end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anise-0.4.0 test/test_attribute_toplevel.rb
anise-0.3.0 test/test_attribute_toplevel.rb