fedora-migrator /vendor/gems/facets-2.4.5/test/core/class/test_cattr.rb

Language Ruby Lines 48
MD5 Hash f4d0ced15650e26b4ef046b32e7e435b Estimated Cost $920 (why?)
Repository https://bitbucket.org/mediashelf/fedora-migrator View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'facets/class/cattr.rb'
require 'test/unit'

class TCModule < Test::Unit::TestCase

  class MockObject
    def initialize
      @@a = 10
    end
    def b ; @@b ; end
  end

  def test_cattr
    assert_nothing_raised {
      MockObject.class_eval { cattr :a }
    }
    t = MockObject.new
    assert_equal( 10, t.a )
  end

  def test_cattr_reader
    assert_nothing_raised {
      MockObject.class_eval { cattr_reader :a }
    }
    t = MockObject.new
    assert_equal( 10, t.a )
  end

  def test_cattr_writer
    assert_nothing_raised {
      MockObject.class_eval { cattr_writer :b }
    }
    t = MockObject.new
    t.b = 5
    assert_equal( 5, t.b )
  end

  def test_cattr_accessor
    assert_nothing_raised {
      MockObject.class_eval { cattr_accessor :c }
    }
    t = MockObject.new
    t.c = 50
    assert_equal( 50, t.c )
  end

end
Back to Top