@@ -72,3 +72,73 @@ def test_instance_method?
7272 assert ( hoge . instance_method? ( 'fugafuga' , false ) )
7373 end
7474end
75+
76+ class TestEntryDescription < Test ::Unit ::TestCase
77+ def parse_class ( class_source )
78+ lib , = BitClust ::RRDParser . parse ( class_source , 'hoge' )
79+ lib . fetch_class ( 'Hoge' )
80+ end
81+
82+ def test_description_truncates_newline_between_non_ascii
83+ klass = parse_class ( <<HERE )
84+ = class Hoge
85+ これは1行目で
86+ あとに続きます。
87+
88+ 以降の段落は含まれません。
89+ HERE
90+ assert_equal ( 'これは1行目であとに続きます。' , klass . description )
91+ end
92+
93+ def test_description_truncates_consecutive_newlines_between_non_ascii
94+ klass = parse_class ( <<HERE )
95+ = class Hoge
96+ あい
97+ うえ
98+ おか。
99+ HERE
100+ assert_equal ( 'あいうえおか。' , klass . description )
101+ end
102+
103+ def test_description_converts_newline_to_space_around_ascii
104+ klass = parse_class ( <<HERE )
105+ = class Hoge
106+ first line
107+ second line
108+ HERE
109+ assert_equal ( 'first line second line' , klass . description )
110+ end
111+
112+ def test_description_replaces_bracket_link_with_plain_text
113+ klass = parse_class ( <<HERE )
114+ = class Hoge
115+ 自身の hostname を文字列で返します。また、[[m:URI::Generic#host]] が設
116+ 定されていない場合は [[c:Array]] を返します。
117+ HERE
118+ assert_equal ( '自身の hostname を文字列で返します。また、URI::Generic#host が設定されていない場合は Array を返します。' ,
119+ klass . description )
120+ end
121+
122+ def test_description_replaces_indexer_bracket_link
123+ klass = parse_class ( <<HERE )
124+ = class Hoge
125+ [[m:String#[] ]] を参照。
126+ HERE
127+ assert_equal ( 'String#[] を参照。' , klass . description )
128+ end
129+
130+ def test_method_description_is_plain_text
131+ klass = parse_class ( <<HERE )
132+ = class Hoge
133+ == Instance Methods
134+ --- fuga
135+
136+ [[c:Array]] を日本語で
137+ 返します。
138+
139+ 次の段落。
140+ HERE
141+ method = klass . entries . detect { |m | m . name == 'fuga' }
142+ assert_equal ( 'Array を日本語で返します。' , method . description )
143+ end
144+ end
0 commit comments