22require File . expand_path '../xref_test_case' , __FILE__
33
44class TestRDocCrossReference < XrefTestCase
5+ OPERATOR_METHODS = %w' == === != =~ !~ < > <= >= <=> [] []= << >> -@ +@ ! - + * / % ** !@ '
56
67 def setup
78 super
@@ -18,9 +19,9 @@ def refute_ref name
1819 end
1920
2021 def test_METHOD_REGEXP_STR
21- re = /#{ RDoc ::CrossReference ::METHOD_REGEXP_STR } /
22+ re = /\A (?: #{ RDoc ::CrossReference ::METHOD_REGEXP_STR } ) \z /
2223
23- %w' == === [] []= << >> ' . each do |x |
24+ OPERATOR_METHODS . each do |x |
2425 re =~ x
2526 assert_equal x , $&
2627 end
@@ -163,34 +164,35 @@ def test_resolve_the_same_name_in_instance_and_class_method
163164 assert_ref @c9_a_c_bar , 'C9::B.bar'
164165 end
165166
166- def test_resolve_method_equals3
167- m = RDoc ::AnyMethod . new '' , '==='
168- @c1 . add_method m
169-
170- assert_ref m , '==='
171- end
172-
173167 def test_resolve_page
174168 page = @store . add_file 'README.txt' , parser : RDoc ::Parser ::Simple
175169
176170 assert_ref page , 'README'
177171 end
178172
179- def test_resolve_percent
180- i_percent = RDoc ::AnyMethod . new nil , '%'
181- i_percent . singleton = false
182- @c1 . add_method i_percent
173+ def assert_resolve_oeprator ( x )
174+ @c1 . methods_hash . clear
175+
176+ i_op = RDoc ::AnyMethod . new nil , x
177+ i_op . singleton = false
178+ @c1 . add_method i_op
183179
184- c_percent = RDoc ::AnyMethod . new nil , '%'
185- c_percent . singleton = true
186- @c1 . add_method c_percent
180+ c_op = RDoc ::AnyMethod . new nil , x
181+ c_op . singleton = true
182+ @c1 . add_method c_op
187183
188- assert_ref i_percent , '%'
189- assert_ref i_percent , '#%'
190- assert_ref c_percent , '::%'
184+ assert_ref i_op , x
185+ assert_ref i_op , "# #{ x } "
186+ assert_ref c_op , ":: #{ x } "
191187
192- assert_ref i_percent , 'C1#%'
193- assert_ref c_percent , 'C1::%'
188+ assert_ref i_op , "C1##{ x } "
189+ assert_ref c_op , "C1::#{ x } "
190+ end
191+
192+ OPERATOR_METHODS . each do |x |
193+ define_method ( "test_resolve_operator:#{ x } " ) do
194+ assert_resolve_oeprator ( x )
195+ end
194196 end
195197
196198 def test_resolve_no_ref
0 commit comments