summaryrefslogtreecommitdiff
path: root/jni/ruby/test/rdoc/test_rdoc_extend.rb
blob: 149931549dd44c5cec3839dc165d4415c2e0854d (plain)
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
require File.expand_path '../xref_test_case', __FILE__

class TestRDocExtend < XrefTestCase

  def setup
    super

    @ext = RDoc::Extend.new 'M1', 'comment'
    @ext.parent = @m1
    @ext.store = @store
  end

  def test_module
    assert_equal @m1, @ext.module
    assert_equal 'Unknown', RDoc::Extend.new('Unknown', 'comment').module
  end

  def test_module_extended
    m1 = @xref_data.add_module RDoc::NormalModule, 'Mod1'
                  m1.add_module RDoc::NormalModule, 'Mod3'
    m1_m2       = m1.add_module RDoc::NormalModule, 'Mod2'
    m1_m2_m3    = m1_m2.add_module RDoc::NormalModule, 'Mod3'
                  m1_m2_m3.add_module RDoc::NormalModule, 'Mod4'
                  m1_m2.add_module RDoc::NormalModule, 'Mod4'
    m1_m2_k0    = m1_m2.add_class RDoc::NormalClass, 'Klass0'
    m1_m2_k0_m4 = m1_m2_k0.add_module RDoc::NormalModule, 'Mod4'
                  m1_m2_k0_m4.add_module RDoc::NormalModule, 'Mod6'
                  m1_m2_k0.add_module RDoc::NormalModule, 'Mod5'

    e0_m4 = RDoc::Extend.new 'Mod4', nil
    e0_m5 = RDoc::Extend.new 'Mod5', nil
    e0_m6 = RDoc::Extend.new 'Mod6', nil
    e0_m1 = RDoc::Extend.new 'Mod1', nil
    e0_m2 = RDoc::Extend.new 'Mod2', nil
    e0_m3 = RDoc::Extend.new 'Mod3', nil

    m1_m2_k0.add_extend e0_m4
    m1_m2_k0.add_extend e0_m5
    m1_m2_k0.add_extend e0_m6
    m1_m2_k0.add_extend e0_m1
    m1_m2_k0.add_extend e0_m2
    m1_m2_k0.add_extend e0_m3

    assert_equal [e0_m4, e0_m5, e0_m6, e0_m1, e0_m2, e0_m3], m1_m2_k0.extends
    assert_equal ['Object'], m1_m2_k0.ancestors

    m1_k1 = m1.add_class RDoc::NormalClass, 'Klass1'

    e1_m1 = RDoc::Extend.new 'Mod1', nil
    e1_m2 = RDoc::Extend.new 'Mod2', nil
    e1_m3 = RDoc::Extend.new 'Mod3', nil
    e1_m4 = RDoc::Extend.new 'Mod4', nil
    e1_k0_m4 = RDoc::Extend.new 'Klass0::Mod4', nil

    m1_k1.add_extend e1_m1
    m1_k1.add_extend e1_m2
    m1_k1.add_extend e1_m3
    m1_k1.add_extend e1_m4
    m1_k1.add_extend e1_k0_m4

    assert_equal [e1_m1, e1_m2, e1_m3, e1_m4, e1_k0_m4], m1_k1.extends
    assert_equal ['Object'], m1_k1.ancestors

    m1_k2 = m1.add_class RDoc::NormalClass, 'Klass2'

    e2_m1 = RDoc::Extend.new 'Mod1', nil
    e2_m2 = RDoc::Extend.new 'Mod2', nil
    e2_m3 = RDoc::Extend.new 'Mod3', nil
    e2_k0_m4 = RDoc::Extend.new 'Klass0::Mod4', nil

    m1_k2.add_extend e2_m1
    m1_k2.add_extend e2_m3
    m1_k2.add_extend e2_m2
    m1_k2.add_extend e2_k0_m4

    assert_equal [e2_m1, e2_m3, e2_m2, e2_k0_m4], m1_k2.extends
    assert_equal ['Object'], m1_k2.ancestors

    m1_k3 = m1.add_class RDoc::NormalClass, 'Klass3'

    e3_m1 = RDoc::Extend.new 'Mod1', nil
    e3_m2 = RDoc::Extend.new 'Mod2', nil
    e3_m4 = RDoc::Extend.new 'Mod4', nil

    m1_k3.add_extend e3_m1
    m1_k3.add_extend e3_m2
    m1_k3.add_extend e3_m4

    assert_equal [e3_m1, e3_m2, e3_m4], m1_k3.extends
    assert_equal ['Object'], m1_k3.ancestors
  end

end