Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix method scope in test in order to invoke the tests properly and fix exception message #182

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions test/parse/test_entity_declaration.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# frozen_string_literal: false
require 'test/unit'
require 'rexml/document'
require "test/unit"
require "core_assertions"

require "rexml/document"

module REXMLTests
class TestParseEntityDeclaration < Test::Unit::TestCase
include Test::Unit::CoreAssertions

private
def xml(internal_subset)
<<-XML
Expand All @@ -18,25 +22,22 @@ def parse(internal_subset)
REXML::Document.new(xml(internal_subset)).doctype
end

public
def test_empty
exception = assert_raise(REXML::ParseException) do
assert_raise(REXML::ParseException) do
parse(<<-INTERNAL_SUBSET)
<!ENTITY>
INTERNAL_SUBSET
end
assert_equal(<<-DETAIL.chomp, exception.to_s)
Malformed notation declaration: name is missing
Line: 5
Position: 72
Last 80 unconsumed characters:
<!ENTITY> ]> <r/>
DETAIL
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test raises following exception:

<"#<NoMethodError: undefined method `captures' for nil>\n" +
"/home/watson/prj/rexml/lib/rexml/parsers/baseparser.rb:321:in `pull_event'\n" +
"/home/watson/prj/rexml/lib/rexml/parsers/baseparser.rb:225:in `pull'\n" +
"/home/watson/prj/rexml/lib/rexml/parsers/treeparser.rb:22:in `parse'\n" +
"/home/watson/prj/rexml/lib/rexml/document.rb:448:in `build'\n" +

I removed because I didn't think the need to check NoMethodError message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should raise ParseException.
Could you fix the implementation in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was wrong above comment. sorry.

It raises ParseException, but it has #<NoMethodError: undefined method captures' for nil>` exception message.

#<REXML::ParseException:"#<NoMethodError: undefined method `captures' for nil>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Then, could you fix the NoMethodError error message in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed with 93ec28f

end

def test_linear_performance_gt
seq = [10000, 50000, 100000, 150000, 200000]
assert_linear_performance(seq, rehearsal: 10) do |n|
REXML::Document.new('<!DOCTYPE rubynet [<!ENTITY rbconfig.ruby_version "' + '>' * n + '">')
begin
REXML::Document.new('<!DOCTYPE rubynet [<!ENTITY rbconfig.ruby_version "' + '>' * n + '">')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a valid XML to reproduce this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed with 36ba79e

rescue
end
end
end
end
Expand Down
Loading