fedora-migrator /vendor/gems/facets-2.4.5/test/more/test_inheritor.rb

Language Ruby Lines 143
MD5 Hash 0304ece27e6f9c911a7b4f590781568e Estimated Cost $2,712 (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
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Test facets/inheritor.rb

require 'facets/inheritor.rb'
require 'test/unit'

#class TC_Inheritor_01 < Test::Unit::TestCase
#  def setup
#    @a = [1]
#    @i = Inheritor.new( @a, [2], :+ )
#  end
#  def test_01_001
#    assert_equal([2],@i)
#  end
#  def test_01_002
#    assert_equal([1,2],@i.inheritance)
#  end
#end

class TC_Inheritor_02 < Test::Unit::TestCase
  class C
    inheritor :koko, [1], :+
  end
  class D < C
    inheritor :koko, [2], :+
  end

  def test_02_001
    assert_equal( [1], C.koko! )
  end
  def test_02_002
    assert_equal( [1], C.koko )
  end
  def test_02_003
    assert_equal( [2], D.koko! )
  end
  def test_02_004
    assert_equal( [1,2], D.koko )
  end
end

class TC_Inheritor_03 < Test::Unit::TestCase
  class C
    inheritor :koko, [1], :+
  end
  class D < C
  end

  def test_03_001
    assert_equal( [1], C.koko! )
  end
  def test_03_002
    assert_equal( [1], C.koko )
  end
  def test_03_003
    assert_equal( [], D.koko! )
  end
  def test_03_004
    assert_equal( [1], D.koko )
  end
end

class TC_Inheritor_04 < Test::Unit::TestCase
  class X
    inheritor :x, {:a=>1}, :merge
  end
  module M
    inheritor :x, {:b=>2}, :merge
  end
  class Y < X
    include M
    inheritor :x, {:c=>3}, :merge
  end

  def test_04_001
    assert_equal( {:a=>1}, X.x )
  end
  def test_04_002
    assert_equal( 2, M.x[:b] )
  end
  def test_04_003
    assert_equal( {:a=>1,:b=>2,:c=>3}, Y.x )
  end
  def test_04_004
    assert_equal( 1, X.x[:a] )
    assert_equal( nil, X.x[:b] )
    assert_equal( nil, X.x[:c] )
  end
  def test_04_005 ; assert_equal( 1, Y.x[:a] ) ; end
  def test_04_006 ; assert_equal( 2, Y.x[:b] ) ; end
  def test_04_007 ; assert_equal( 3, Y.x[:c] ) ; end
  def test_04_008
    Y.x![:d] = 4
    assert_equal( 4, Y.x[:d] )
  end
end

class TC_Inheritor_05 < Test::Unit::TestCase
  class C
    inheritor :relations, [], :concat
  end
  class D < C
    #inheritor :relations, [], :concat
  end

  C.relations! << 1
  C.relations! << 2
  D.relations! << 3

  def test_05_001
    assert_equal( [1,2], C.relations )
    assert_equal( [1,2,3], D.relations )
  end
end

class TC_Inheritor_06 < Test::Unit::TestCase
  module MM
    inheritor :koko, [], :+
    koko! << 1
  end
  class CC1
    include MM
    #inheritor :koko, [], :+
    koko! << 2
    koko! << 3
  end
  class CC2
    include MM
    #inheritor :koko, [], :+
    koko! << 4
  end

  def test_06_001
    assert_equal( [1], MM.koko )
  end
  def test_06_002
    assert_equal( [1,2,3], CC1.koko )
  end
  def test_06_003
    assert_equal( [1,4], CC2.koko )
  end
end
Back to Top