[ruby/uri] Added test for constant definition and remove URI::REGEXP when using RFC3986_PARSER
https://github.com/ruby/uri/commit/6f616d97fc
This commit is contained in:
parent
2a56c1841d
commit
082335494b
@ -26,8 +26,8 @@ module URI
|
|||||||
remove_const(:Parser) if defined?(Parser)
|
remove_const(:Parser) if defined?(Parser)
|
||||||
const_set("Parser", parser.class)
|
const_set("Parser", parser.class)
|
||||||
|
|
||||||
|
remove_const(:REGEXP) if defined?(REGEXP)
|
||||||
if Parser == RFC2396_Parser
|
if Parser == RFC2396_Parser
|
||||||
remove_const(:REGEXP) if defined?(REGEXP)
|
|
||||||
const_set("REGEXP", URI::RFC2396_REGEXP)
|
const_set("REGEXP", URI::RFC2396_REGEXP)
|
||||||
Parser.new.pattern.each_pair do |sym, str|
|
Parser.new.pattern.each_pair do |sym, str|
|
||||||
unless REGEXP::PATTERN.const_defined?(sym)
|
unless REGEXP::PATTERN.const_defined?(sym)
|
||||||
@ -35,6 +35,7 @@ module URI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Parser.new.regexp.each_pair do |sym, str|
|
Parser.new.regexp.each_pair do |sym, str|
|
||||||
remove_const(sym) if const_defined?(sym)
|
remove_const(sym) if const_defined?(sym)
|
||||||
const_set(sym, str)
|
const_set(sym, str)
|
||||||
|
@ -10,6 +10,23 @@ class URI::TestCommon < Test::Unit::TestCase
|
|||||||
def teardown
|
def teardown
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_parser_switch
|
||||||
|
assert_equal(URI::Parser, URI::RFC3986_Parser)
|
||||||
|
refute defined?(::URI::REGEXP)
|
||||||
|
|
||||||
|
URI.parser = URI::RFC2396_PARSER
|
||||||
|
|
||||||
|
assert_equal(URI::Parser, URI::RFC2396_Parser)
|
||||||
|
assert defined?(URI::REGEXP)
|
||||||
|
|
||||||
|
URI.parser = URI::RFC3986_PARSER
|
||||||
|
|
||||||
|
assert_equal(URI::Parser, URI::RFC3986_Parser)
|
||||||
|
refute defined?(URI::REGEXP)
|
||||||
|
ensure
|
||||||
|
URI.parser = URI::RFC3986_PARSER
|
||||||
|
end
|
||||||
|
|
||||||
def test_extract
|
def test_extract
|
||||||
EnvUtil.suppress_warning do
|
EnvUtil.suppress_warning do
|
||||||
assert_equal(['http://example.com'],
|
assert_equal(['http://example.com'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user