diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-06-25 13:38:01 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-07-27 16:54:27 +0900 |
commit | 1cf111774f03c6d1ddba735cb8cc79483f16f699 (patch) | |
tree | b90249839fb24c0d350544eda50666e95c5d968b /test/uri/test_common.rb | |
parent | 090d799c2496f4c0e1f25c9970f4015fc693ff0e (diff) |
[ruby/uri] Add proper Ractor support to URI
* Using a module to map scheme name to scheme class, which also works with Ractor.
* No constant redefinition, no ObjectSpace, still fast lookup for initial schemes.
https://github.com/ruby/uri/commit/883567fd81
Diffstat (limited to 'test/uri/test_common.rb')
-rw-r--r-- | test/uri/test_common.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 1afa35f93d..3d281758f4 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -33,6 +33,26 @@ class TestCommon < Test::Unit::TestCase end end + def test_ractor + return unless defined?(Ractor) + r = Ractor.new { URI.parse("https://ruby-lang.org/").inspect } + assert_equal(URI.parse("https://ruby-lang.org/").inspect, r.take) + end + + def test_register_scheme + assert_equal(["FILE", "FTP", "HTTP", "HTTPS", "LDAP", "LDAPS", "MAILTO", "WS"].sort, URI.scheme_list.keys.sort) + + foobar = Class.new(URI::Generic) + URI.register_scheme 'FOOBAR', foobar + begin + assert_equal(["FILE", "FTP", "HTTP", "HTTPS", "LDAP", "LDAPS", "MAILTO", "WS", "FOOBAR"].sort, URI.scheme_list.keys.sort) + ensure + URI.const_get(:Schemes).send(:remove_const, :FOOBAR) + end + + assert_equal(["FILE", "FTP", "HTTP", "HTTPS", "LDAP", "LDAPS", "MAILTO", "WS"].sort, URI.scheme_list.keys.sort) + end + def test_regexp EnvUtil.suppress_warning do assert_instance_of Regexp, URI.regexp |