Skip to content

Commit

Permalink
Add tests to cover line numbering edge cases with JRuby
Browse files Browse the repository at this point in the history
  • Loading branch information
dabdine committed Dec 8, 2021
1 parent cc5a7ea commit 102e58a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/xml/test_node.rb
Expand Up @@ -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)
<?xml version="1.0" ?>
<a>
<b>
Test
</b>
</root>
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)
<a>
<b>
<!-- This is a comment -->
<c>
Test
</c>
</b>
</a>
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)
<a>
<b>
<!--
This is a comment
-->
<c>
Test
</c>
</b>
</a>
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)
<a>
Expand Down

0 comments on commit 102e58a

Please sign in to comment.