diff --git a/test/xml/test_node.rb b/test/xml/test_node.rb index b179a6fdaf8..41e167eea2f 100644 --- a/test/xml/test_node.rb +++ b/test/xml/test_node.rb @@ -1242,6 +1242,54 @@ def test_wrap end describe "#line" do + it "properly numbers lines with documents containing XML prolog" do + xml = Nokogiri::XML(<<~eoxml) + + + + Test + + + eoxml + + set = xml.search("//b") + assert_equal(3, set[0].line) + end + + it "properly numbers lines with documents containing XML comments" do + xml = Nokogiri::XML(<<~eoxml) + + + + + Test + + + + eoxml + + set = xml.search("//c") + assert_equal(4, set[0].line) + end + + it "properly numbers lines with documents containing XML multiline comments" do + xml = Nokogiri::XML(<<~eoxml) + + + + + Test + + + + eoxml + + set = xml.search("//c") + assert_equal(6, set[0].line) + end + it "returns a sensible line number for each node" do xml = Nokogiri::XML(<<~eoxml)