diff options
author | Semyon Pupkov <mail@semyonpupkov.com> | 2017-11-13 14:48:29 +0500 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-08-04 09:19:30 +0900 |
commit | 4173258fd0413c49ef07d54bc9654bba7e497e89 (patch) | |
tree | 74f0024198404b5b455eaed5b0c39d5a9076e468 /test/cgi/test_cgi_util.rb | |
parent | 8e7df4bbf991b9d605784225db0750bbfe681f23 (diff) | |
download | ruby-4173258fd0413c49ef07d54bc9654bba7e497e89.tar.gz |
change call CGI methods from :: to .
Closes: https://github.com/ruby/ruby/pull/1749
Diffstat (limited to 'test/cgi/test_cgi_util.rb')
-rw-r--r-- | test/cgi/test_cgi_util.rb | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb index f2f5575efb..fa1c1e5959 100644 --- a/test/cgi/test_cgi_util.rb +++ b/test/cgi/test_cgi_util.rb @@ -25,30 +25,30 @@ class CGIUtilTest < Test::Unit::TestCase def test_cgi_escape - assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93', CGI::escape(@str1)) - assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93'.ascii_only?, CGI::escape(@str1).ascii_only?) if defined?(::Encoding) + assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93', CGI.escape(@str1)) + assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93'.ascii_only?, CGI.escape(@str1).ascii_only?) if defined?(::Encoding) end def test_cgi_escape_with_unreserved_characters assert_equal("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~", - CGI::escape("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"), + CGI.escape("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"), "should not escape any unreserved characters, as per RFC3986 Section 2.3") end def test_cgi_escape_with_invalid_byte_sequence assert_nothing_raised(ArgumentError) do - assert_equal('%C0%3C%3C', CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8"))) + assert_equal('%C0%3C%3C', CGI.escape("\xC0\<\<".dup.force_encoding("UTF-8"))) end end def test_cgi_escape_preserve_encoding - assert_equal(Encoding::US_ASCII, CGI::escape("\xC0\<\<".dup.force_encoding("US-ASCII")).encoding) - assert_equal(Encoding::ASCII_8BIT, CGI::escape("\xC0\<\<".dup.force_encoding("ASCII-8BIT")).encoding) - assert_equal(Encoding::UTF_8, CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8")).encoding) + assert_equal(Encoding::US_ASCII, CGI.escape("\xC0\<\<".dup.force_encoding("US-ASCII")).encoding) + assert_equal(Encoding::ASCII_8BIT, CGI.escape("\xC0\<\<".dup.force_encoding("ASCII-8BIT")).encoding) + assert_equal(Encoding::UTF_8, CGI.escape("\xC0\<\<".dup.force_encoding("UTF-8")).encoding) end def test_cgi_unescape - str = CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93') + str = CGI.unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93') assert_equal(@str1, str) return unless defined?(::Encoding) @@ -57,9 +57,9 @@ class CGIUtilTest < Test::Unit::TestCase end def test_cgi_unescape_preserve_encoding - assert_equal(Encoding::US_ASCII, CGI::unescape("%C0%3C%3C".dup.force_encoding("US-ASCII")).encoding) - assert_equal(Encoding::ASCII_8BIT, CGI::unescape("%C0%3C%3C".dup.force_encoding("ASCII-8BIT")).encoding) - assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".dup.force_encoding("UTF-8")).encoding) + assert_equal(Encoding::US_ASCII, CGI.unescape("%C0%3C%3C".dup.force_encoding("US-ASCII")).encoding) + assert_equal(Encoding::ASCII_8BIT, CGI.unescape("%C0%3C%3C".dup.force_encoding("ASCII-8BIT")).encoding) + assert_equal(Encoding::UTF_8, CGI.unescape("%C0%3C%3C".dup.force_encoding("UTF-8")).encoding) end def test_cgi_unescape_accept_charset @@ -73,23 +73,23 @@ class CGIUtilTest < Test::Unit::TestCase end def test_cgi_pretty - assert_equal("<HTML>\n <BODY>\n </BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>")) - assert_equal("<HTML>\n\t<BODY>\n\t</BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>","\t")) + assert_equal("<HTML>\n <BODY>\n </BODY>\n</HTML>\n",CGI.pretty("<HTML><BODY></BODY></HTML>")) + assert_equal("<HTML>\n\t<BODY>\n\t</BODY>\n</HTML>\n",CGI.pretty("<HTML><BODY></BODY></HTML>","\t")) end def test_cgi_escapeHTML - assert_equal("'&"><", CGI::escapeHTML("'&\"><")) + assert_equal("'&"><", CGI.escapeHTML("'&\"><")) end def test_cgi_escape_html_duplicated orig = "Ruby".dup.force_encoding("US-ASCII") - str = CGI::escapeHTML(orig) + str = CGI.escapeHTML(orig) assert_equal(orig, str) assert_not_same(orig, str) end def assert_cgi_escape_html_preserve_encoding(str, encoding) - assert_equal(encoding, CGI::escapeHTML(str.dup.force_encoding(encoding)).encoding) + assert_equal(encoding, CGI.escapeHTML(str.dup.force_encoding(encoding)).encoding) end def test_cgi_escape_html_preserve_encoding @@ -100,25 +100,25 @@ class CGIUtilTest < Test::Unit::TestCase end def test_cgi_escape_html_preserve_tainted - assert_not_predicate CGI::escapeHTML("'&\"><"), :tainted? - assert_predicate CGI::escapeHTML("'&\"><".dup.taint), :tainted? - assert_not_predicate CGI::escapeHTML("Ruby"), :tainted? - assert_predicate CGI::escapeHTML("Ruby".dup.taint), :tainted? + assert_not_predicate CGI.escapeHTML("'&\"><"), :tainted? + assert_predicate CGI.escapeHTML("'&\"><".dup.taint), :tainted? + assert_not_predicate CGI.escapeHTML("Ruby"), :tainted? + assert_predicate CGI.escapeHTML("Ruby".dup.taint), :tainted? end def test_cgi_escape_html_dont_freeze - assert_not_predicate CGI::escapeHTML("'&\"><".dup), :frozen? - assert_not_predicate CGI::escapeHTML("'&\"><".freeze), :frozen? - assert_not_predicate CGI::escapeHTML("Ruby".dup), :frozen? - assert_not_predicate CGI::escapeHTML("Ruby".freeze), :frozen? + assert_not_predicate CGI.escapeHTML("'&\"><".dup), :frozen? + assert_not_predicate CGI.escapeHTML("'&\"><".freeze), :frozen? + assert_not_predicate CGI.escapeHTML("Ruby".dup), :frozen? + assert_not_predicate CGI.escapeHTML("Ruby".freeze), :frozen? end def test_cgi_unescapeHTML - assert_equal("'&\"><", CGI::unescapeHTML("'&"><")) + assert_equal("'&\"><", CGI.unescapeHTML("'&"><")) end def test_cgi_unescapeHTML_invalid - assert_equal('&<&>"&abcdefghijklmn', CGI::unescapeHTML('&<&>"&abcdefghijklmn')) + assert_equal('&<&>"&abcdefghijklmn', CGI.unescapeHTML('&<&>"&abcdefghijklmn')) end Encoding.list.each do |enc| @@ -129,10 +129,10 @@ class CGIUtilTest < Test::Unit::TestCase next else define_method("test_cgi_escapeHTML:#{enc.name}") do - assert_equal(escaped, CGI::escapeHTML(unescaped)) + assert_equal(escaped, CGI.escapeHTML(unescaped)) end define_method("test_cgi_unescapeHTML:#{enc.name}") do - assert_equal(unescaped, CGI::unescapeHTML(escaped)) + assert_equal(unescaped, CGI.unescapeHTML(escaped)) end end end @@ -146,16 +146,16 @@ class CGIUtilTest < Test::Unit::TestCase next else define_method("test_cgi_escape:#{enc.name}") do - assert_equal(escaped, CGI::escape(unescaped)) + assert_equal(escaped, CGI.escape(unescaped)) end define_method("test_cgi_unescape:#{enc.name}") do - assert_equal(unescaped, CGI::unescape(escaped, enc)) + assert_equal(unescaped, CGI.unescape(escaped, enc)) end end end def test_cgi_unescapeHTML_uppercasecharacter - assert_equal("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86", CGI::unescapeHTML("あいう")) + assert_equal("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86", CGI.unescapeHTML("あいう")) end def test_cgi_include_escape |