Sha256: df668b595160eb374401d3e19beccea2e5a3e6e4ddd25abfa22bfd36e4e5c648

Contents?: true

Size: 911 Bytes

Versions: 16

Compression:

Stored size: 911 Bytes

Contents

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/kernel/test_attr_singleton.rb
facets-2.8.3 test/core/kernel/test_attr_singleton.rb
facets-2.8.2 test/core/kernel/test_attr_singleton.rb
facets-2.8.1 test/core/kernel/test_attr_singleton.rb
facets-2.8.0 test/core/kernel/test_attr_singleton.rb
facets-2.7.0 test/core/kernel/test_attr_singleton.rb
facets-2.6.0 test/core/kernel/test_attr_singleton.rb
facets-2.4.0 test/kernel/test_attr_singleton.rb
facets-2.4.1 test/kernel/test_attr_singleton.rb
facets-2.4.4 test/core/kernel/test_attr_singleton.rb
facets-2.4.3 test/core/kernel/test_attr_singleton.rb
facets-2.4.2 test/core/kernel/test_attr_singleton.rb
facets-2.5.1 test/core/kernel/test_attr_singleton.rb
facets-2.5.0 test/core/kernel/test_attr_singleton.rb
facets-2.4.5 test/core/kernel/test_attr_singleton.rb
facets-2.5.2 test/core/kernel/test_attr_singleton.rb