diff --git a/test/xml/test_document.rb b/test/xml/test_document.rb
index 036ecb9af4..bf37c2c5ba 100644
--- a/test/xml/test_document.rb
+++ b/test/xml/test_document.rb
@@ -809,6 +809,22 @@ def test_dup
assert dup.xml?, 'duplicate should be xml'
end
+ def test_dup_xml_document_errors
+ html = "
replace me
"
+
+ doc = Nokogiri::XML::Document.parse(html)
+ doc2 = doc.dup
+
+ child = doc.css('body').children[0]
+ child2 = doc2.css('body').children[0]
+
+ assert_equal doc, child.document
+ assert_equal doc.errors, child.document.errors
+
+ assert_equal doc2, child2.document
+ assert_equal doc2.errors, child2.document.errors
+ end
+
def test_new
doc = nil
doc = Nokogiri::XML::Document.new