diff options
author | Mike Dalessio <[email protected]> | 2024-11-30 07:31:36 -0500 |
---|---|---|
committer | git <[email protected]> | 2024-11-30 12:31:42 +0000 |
commit | 2923f42ed7622f6310c63aab4c0abf05402f9a04 (patch) | |
tree | cc76e44356eb4c12dc3268c3615aeac8d09e9cb8 /test | |
parent | 3d07754ee2c707343f79321b0fd358af3154709f (diff) |
[ruby/rdoc] fix: C variables should never show up in Ancestors tree
(https://github.com/ruby/rdoc/pull/1217)
If a NormalClass's superclass is a C enclosure, then update the
superclass to point to the RDoc::NormalClass.
This is done in a single pass after all files have been parsed.
Fixes https://github.com/ruby/rdoc/pull/1205.
https://github.com/ruby/rdoc/commit/1ecd9581b1
Diffstat (limited to 'test')
-rw-r--r-- | test/rdoc/test_rdoc_store.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index 50e8667d81..2665f163e4 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -281,6 +281,26 @@ class TestRDocStore < XrefTestCase assert_nil @s.find_c_enclosure('cObject') end + def test_resolve_c_superclasses + # first parse a child that references an unknown parent + c_file1 = @s.add_file 'ext1.c' + c_file1.add_class RDoc::NormalClass, 'Child', 'cExternParent' + + # then parse the parent and register the C variable name as a C enclosure + c_file2 = @s.add_file 'ext2.c' + parent = c_file2.add_class RDoc::NormalClass, 'Parent', 'rb_cObject' + + @s.add_c_enclosure('cExternParent', parent) + + # at this point, the child's superclass is still the name of the C variable + assert_equal("cExternParent", @s.classes_hash['Child'].superclass) + + @s.resolve_c_superclasses + + # now the ancestor tree correctly references the NormalClass objects + assert_equal(parent, @s.classes_hash['Child'].superclass) + end + def test_find_class_named assert_equal @c1, @store.find_class_named('C1') |