diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-15 23:23:39 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-15 23:23:39 +0000 |
commit | 6175ca03be6d0d51359f9017123708987d0f5eb7 (patch) | |
tree | ecfcf6e79a21b1d25c3f6f42dd68ea0a14add89c /ruby_1_8_5/test/uri/test_common.rb | |
parent | 80a56b248b2e9cfc95622aed98750df05a19f667 (diff) |
add tag v1_8_5_91v1_8_5_91
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_91@13046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_5/test/uri/test_common.rb')
-rw-r--r-- | ruby_1_8_5/test/uri/test_common.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ruby_1_8_5/test/uri/test_common.rb b/ruby_1_8_5/test/uri/test_common.rb new file mode 100644 index 0000000000..a159901ea6 --- /dev/null +++ b/ruby_1_8_5/test/uri/test_common.rb @@ -0,0 +1,56 @@ +require 'test/unit' +require 'uri' + +module URI + + +class TestCommon < Test::Unit::TestCase + def setup + end + + def teardown + end + + def test_extract + # ruby-list:36086 + assert_equal(['http://example.com'], + URI.extract('http://example.com')) + assert_equal(['http://example.com'], + URI.extract('(http://example.com)')) + assert_equal(['http://example.com/foo)'], + URI.extract('(http://example.com/foo)')) + assert_equal(['http://example.jphttp://example.jp'], + URI.extract('http://example.jphttp://example.jp')) + assert_equal(['http://example.jphttp://example.jp'], + URI.extract('http://example.jphttp://example.jp', ['http'])) + assert_equal(['http://', 'mailto:'].sort, + URI.extract('ftp:// http:// mailto: https://', ['http', 'mailto']).sort) + # reported by Doug Kearns <djkea2@mugca.its.monash.edu.au> + assert_equal(['From:', 'mailto:xxx@xxx.xxx.xxx]'].sort, + URI.extract('From: XXX [mailto:xxx@xxx.xxx.xxx]').sort) + end + + def test_regexp + assert_instance_of Regexp, URI.regexp + assert_instance_of Regexp, URI.regexp(['http']) + assert_equal URI.regexp, URI.regexp + assert_equal 'http://', 'x http:// x'.slice(URI.regexp) + assert_equal 'http://', 'x http:// x'.slice(URI.regexp(['http'])) + assert_equal 'http://', 'x http:// x ftp://'.slice(URI.regexp(['http'])) + assert_equal nil, 'http://'.slice(URI.regexp([])) + assert_equal nil, ''.slice(URI.regexp) + assert_equal nil, 'xxxx'.slice(URI.regexp) + assert_equal nil, ':'.slice(URI.regexp) + assert_equal 'From:', 'From:'.slice(URI.regexp) + end + + def test_kernel_uri + expected = URI.parse("http://www.ruby-lang.org/") + assert_equal(expected, URI("http://www.ruby-lang.org/")) + assert_equal(expected, Kernel::URI("http://www.ruby-lang.org/")) + assert_raise(NoMethodError) { Object.new.URI("http://www.ruby-lang.org/") } + end +end + + +end |