Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the known classes more #896

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/rdoc/known_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ module RDoc
"rb_eInterrupt" => "Interrupt",
"rb_eLoadError" => "LoadError",
"rb_eNameError" => "NameError",
"rb_eNoMemError" => "NoMemError",
"rb_eNotImpError" => "NotImpError",
"rb_eNoMemError" => "NoMemoryError",
"rb_eNotImpError" => "NotImplementedError",
"rb_eRangeError" => "RangeError",
"rb_eRuntimeError" => "RuntimeError",
"rb_eScriptError" => "ScriptError",
Expand All @@ -58,7 +58,7 @@ module RDoc
"rb_eSystemCallError" => "SystemCallError",
"rb_eSystemExit" => "SystemExit",
"rb_eTypeError" => "TypeError",
"rb_eZeroDivError" => "ZeroDivError",
"rb_eZeroDivError" => "ZeroDivisionError",

"rb_mComparable" => "Comparable",
"rb_mEnumerable" => "Enumerable",
Expand Down
27 changes: 25 additions & 2 deletions test/rdoc/test_rdoc_parser_c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ def test_class_can_parse
end
end

def test_known_classes
RDoc::KNOWN_CLASSES.each do |var, name|
case name
when "Refinement"
next unless defined?(Refinement)
when "RubyVM"
next unless defined?(RubyVM)
when "Bignum", "Fixnum", "Data", "Socket", /\A(?![A-Z])/
next
end
obj = Object.const_get(name)
assert_equal obj.name, name
case var
when /\Arb_c/
assert_kind_of Class, obj
when /\Arb_m/
assert_kind_of Module, obj
when /\Arb_e/
assert_operator obj, :<=, Exception
else
raise "unknown prefix: #{var} => #{name}"
end
end
end

def test_initialize
some_ext = @top_level.add_class RDoc::NormalClass, 'SomeExt'
@top_level.add_class RDoc::SingleClass, 'SomeExtSingle'
Expand All @@ -115,8 +140,6 @@ def test_initialize

parser = RDoc::Parser::C.new @top_level, @fn, '', @options, @stats

assert_equal "ArgumentError", parser.known_classes["rb_eArgError"]

expected = { 'cSomeExt' => some_ext }
assert_equal expected, parser.classes

Expand Down