/vendor/gems/facets-2.4.5/test/core/kernel/test_attr_singleton.rb
Ruby | 41 lines | 33 code | 8 blank | 0 comment | 0 complexity | 010b6bf252f9c67e9754e0f8ef10dd23 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
- require 'facets/kernel/attr_singleton.rb'
- require 'test/unit'
- class TestAttrSingleton < Test::Unit::TestCase
- class AttrSingletonMock
- def initialize
- attr_singleton_reader :foo #=> "FOO"
- attr_singleton_writer :bar #=> "BAR"
- attr_singleton_accessor :baz #=> "BAZ"
- @foo = "FOO"
- self.bar = "BAR"
- self.baz = "BAZ"
- end
- def get_bar
- @bar
- end
- end
- def test_attr_singleton_reader
- assert_nothing_raised { @t = AttrSingletonMock.new }
- assert_equal("FOO", @t.foo)
- end
- def test_attr_singleton_writer
- assert_nothing_raised { @t = AttrSingletonMock.new }
- assert_equal("BAR", @t.get_bar)
- @t.bar = "BAR2"
- assert_equal("BAR2", @t.get_bar)
- end
- def test_attr_singleton_accessor
- assert_nothing_raised { @t = AttrSingletonMock.new }
- assert_equal("BAZ", @t.baz)
- @t.baz = "BAZ2"
- assert_equal("BAZ2", @t.baz)
- end
- end