PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/kernel/test_attr_singleton.rb

https://bitbucket.org/mediashelf/fedora-migrator
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
  1. require 'facets/kernel/attr_singleton.rb'
  2. require 'test/unit'
  3. class TestAttrSingleton < Test::Unit::TestCase
  4. class AttrSingletonMock
  5. def initialize
  6. attr_singleton_reader :foo #=> "FOO"
  7. attr_singleton_writer :bar #=> "BAR"
  8. attr_singleton_accessor :baz #=> "BAZ"
  9. @foo = "FOO"
  10. self.bar = "BAR"
  11. self.baz = "BAZ"
  12. end
  13. def get_bar
  14. @bar
  15. end
  16. end
  17. def test_attr_singleton_reader
  18. assert_nothing_raised { @t = AttrSingletonMock.new }
  19. assert_equal("FOO", @t.foo)
  20. end
  21. def test_attr_singleton_writer
  22. assert_nothing_raised { @t = AttrSingletonMock.new }
  23. assert_equal("BAR", @t.get_bar)
  24. @t.bar = "BAR2"
  25. assert_equal("BAR2", @t.get_bar)
  26. end
  27. def test_attr_singleton_accessor
  28. assert_nothing_raised { @t = AttrSingletonMock.new }
  29. assert_equal("BAZ", @t.baz)
  30. @t.baz = "BAZ2"
  31. assert_equal("BAZ2", @t.baz)
  32. end
  33. end