diff --git a/test/test_compaction.rb b/test/test_compaction.rb
index 5b0720f670..e06d36d40d 100644
--- a/test/test_compaction.rb
+++ b/test/test_compaction.rb
@@ -3,19 +3,41 @@
require "helper"
describe "compaction" do
- it "https://github.com/sparklemotion/nokogiri/pull/2579" do
- skip unless GC.respond_to?(:verify_compaction_references)
+ describe Nokogiri::XML::Node do
+ it "compacts safely" do # https://github.com/sparklemotion/nokogiri/pull/2579
+ skip unless GC.respond_to?(:verify_compaction_references)
- big_doc = "" + ("a".."zz").map { |x| "<#{x}>#{x}#{x}>" }.join + ""
- doc = Nokogiri.XML(big_doc)
+ big_doc = "" + ("a".."zz").map { |x| "<#{x}>#{x}#{x}>" }.join + ""
+ doc = Nokogiri.XML(big_doc)
- # ensure a bunch of node objects have been wrapped
- doc.root.children.each(&:inspect)
+ # ensure a bunch of node objects have been wrapped
+ doc.root.children.each(&:inspect)
- # compact the heap and try to get the node wrappers to move
- GC.verify_compaction_references(double_heap: true, toward: :empty)
+ # compact the heap and try to get the node wrappers to move
+ GC.verify_compaction_references(double_heap: true, toward: :empty)
- # access the node wrappers and make sure they didn't move
- doc.root.children.each(&:inspect)
+ # access the node wrappers and make sure they didn't move
+ doc.root.children.each(&:inspect)
+ end
+ end
+
+ describe Nokogiri::XML::Namespace do
+ it "namespace_scopes" do
+ skip unless GC.respond_to?(:verify_compaction_references)
+
+ doc = Nokogiri::XML(<<~EOF)
+
+
+
+
+
+ EOF
+
+ doc.at_xpath("//root:first", "root" => "http://example.com/root").namespace_scopes.inspect
+
+ GC.verify_compaction_references(double_heap: true, toward: :empty)
+
+ doc.at_xpath("//root:first", "root" => "http://example.com/root").namespace_scopes.inspect
+ end
end
end