From 556f8054938060c2021a49b60f44fd6b679e446e Mon Sep 17 00:00:00 2001 From: hsbt Date: Sat, 9 Aug 2014 01:19:18 +0000 Subject: * test/cgi/test_cgi_core.rb: removed obsoleted condition for Ruby 1.8. * test/cgi/test_cgi_header.rb: ditto. * test/cgi/test_cgi_multipart.rb: ditto. * test/cgi/test_cgi_tag_helper.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/cgi/test_cgi_core.rb | 65 ++--------------------------------------- test/cgi/test_cgi_header.rb | 8 ++--- test/cgi/test_cgi_multipart.rb | 28 ++++++++---------- test/cgi/test_cgi_tag_helper.rb | 12 ++++---- 4 files changed, 21 insertions(+), 92 deletions(-) (limited to 'test') diff --git a/test/cgi/test_cgi_core.rb b/test/cgi/test_cgi_core.rb index 123caf7acd..274d088f0f 100644 --- a/test/cgi/test_cgi_core.rb +++ b/test/cgi/test_cgi_core.rb @@ -31,7 +31,7 @@ class CGICoreTest < Test::Unit::TestCase } ENV.update(@environ) cgi = CGI.new - assert_equal(["a","b","c","d"],cgi.keys.sort) if RUBY_VERSION>="1.9" + assert_equal(["a","b","c","d"],cgi.keys.sort) assert_equal("",cgi["d"]) end @@ -48,27 +48,6 @@ class CGICoreTest < Test::Unit::TestCase ## cgi[] assert_equal('123', cgi['id']) assert_equal('@h =~ /^$/', cgi['str']) - ## cgi[][], cgi[].first, cgi[].to_ary (obsolete 1.9) - if RUBY_VERSION<"1.9" - $stderr = StringIO.new - begin - assert_equal('123', cgi['id'][0]) - assert_equal('456', cgi['id'][1]) - assert_equal('', cgi['id'][2]) - assert_nil(cgi['id'][3]) - assert_equal('@h =~ /^$/', cgi['str'][0]) - assert_nil(cgi['str'][1]) - assert_equal('123', cgi['id'].first) - assert_equal('123', cgi['id'].last) # should be '' ? - id1, id2, id3 = cgi['id'] - assert_equal(['123', '456', ''], [id1, id2, id3]) - str1, = cgi['str'] - assert_equal('@h =~ /^$/', str1) - assert_not_same(str1, cgi['str']) # necessary? - ensure - $stderr = STDERR - end - end ## cgi.params assert_equal(['123', '456', ''], cgi.params['id']) assert_equal(['@h =~ /^$/'], cgi.params['str']) @@ -199,48 +178,8 @@ class CGICoreTest < Test::Unit::TestCase } ENV.update(@environ) cgi = CGI.new - ## jis, euc, sjis string - jis_str = "\e$B8+$m!\"?M$,%4%_$N$h$&$@\e(B" + ## euc string euc_str = "\270\253\244\355\241\242\277\315\244\254\245\264\245\337\244\316\244\350\244\246\244\300" - sjis_str = "\214\251\202\353\201A\220l\202\252\203S\203~\202\314\202\346\202\244\202\276" - if RUBY_VERSION<"1.9" - ## iso-2022-jp - options = { 'charset'=>'iso-2022-jp' } - $stdout = StringIO.new - cgi.out(options) { euc_str } - assert_equal('ja', options['language']) - actual = $stdout.string - expected = "Content-Type: text/html; charset=iso-2022-jp\r\n" + - "Content-Length: 28\r\n" + - "Content-Language: ja\r\n" + - "\r\n" + - jis_str - assert_equal(expected,actual) - ## euc-jp - options = { 'charset'=>'EUC-JP' } - $stdout = StringIO.new - cgi.out(options) { euc_str } - assert_equal('ja', options['language']) - actual = $stdout.string - expected = "Content-Type: text/html; charset=EUC-JP\r\n" + - "Content-Length: 22\r\n" + - "Content-Language: ja\r\n" + - "\r\n" + - euc_str - assert_equal(expected, actual) - ## shift_jis - options = { 'charset'=>'Shift_JIS' } - $stdout = StringIO.new - cgi.out(options) { euc_str } - assert_equal('ja', options['language']) - actual = $stdout.string - expected = "Content-Type: text/html; charset=Shift_JIS\r\n" + - "Content-Length: 22\r\n" + - "Content-Language: ja\r\n" + - "\r\n" + - sjis_str - assert_equal(expected, actual) - end ## utf8 (not converted) options = { 'charset'=>'utf8' } $stdout = StringIO.new diff --git a/test/cgi/test_cgi_header.rb b/test/cgi/test_cgi_header.rb index c6306eb0ff..9022301153 100644 --- a/test/cgi/test_cgi_header.rb +++ b/test/cgi/test_cgi_header.rb @@ -71,12 +71,8 @@ class CGIHeaderTest < Test::Unit::TestCase def test_cgi_http_header_argerr cgi = CGI.new - #expected = NoMethodError # must be ArgumentError - if RUBY_VERSION>="1.9.0" - expected = ArgumentError # for CGIAlt - else - expected = NoMethodError # for Ruby1.8 - end + expected = ArgumentError + assert_raise(expected) do cgi.http_header(nil) end diff --git a/test/cgi/test_cgi_multipart.rb b/test/cgi/test_cgi_multipart.rb index 989ac7aba8..806adbd013 100644 --- a/test/cgi/test_cgi_multipart.rb +++ b/test/cgi/test_cgi_multipart.rb @@ -152,24 +152,20 @@ class CGIMultipartTest < Test::Unit::TestCase _prepare(@data) options = {:accept_charset=>"UTF-8"} options.merge! cgi_options - cgi = RUBY_VERSION>="1.9" ? CGI.new(options) : CGI.new + cgi = CGI.new(options) expected_names = @data.collect{|hash| hash[:name] }.sort assert_equal(expected_names, cgi.params.keys.sort) threshold = 1024*10 @data.each do |hash| name = hash[:name] expected = hash[:value] - if RUBY_VERSION>="1.9" - if hash[:filename] #if file - expected_class = @expected_class || (hash[:value].length < threshold ? StringIO : Tempfile) - assert(cgi.files.keys.member?(hash[:name])) - else - expected_class = String - assert_equal(expected, cgi[name]) - assert_equal(false,cgi.files.keys.member?(hash[:name])) - end - else + if hash[:filename] #if file expected_class = @expected_class || (hash[:value].length < threshold ? StringIO : Tempfile) + assert(cgi.files.keys.member?(hash[:name])) + else + expected_class = String + assert_equal(expected, cgi[name]) + assert_equal(false,cgi.files.keys.member?(hash[:name])) end assert_kind_of(expected_class, cgi[name]) assert_equal(expected, cgi[name].read()) @@ -301,7 +297,7 @@ class CGIMultipartTest < Test::Unit::TestCase input2 end ex = assert_raise(EOFError) do - RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new + CGI.new(:accept_charset=>"UTF-8") end assert_equal("bad content body", ex.message) # @@ -312,7 +308,7 @@ class CGIMultipartTest < Test::Unit::TestCase input2 end ex = assert_raise(EOFError) do - RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new + CGI.new(:accept_charset=>"UTF-8") end assert_equal("bad content body", ex.message) end @@ -328,9 +324,9 @@ class CGIMultipartTest < Test::Unit::TestCase {:name=>'image1', :value=>_read('small.png'), :filename=>'small.png', :content_type=>'image/png'}, # small image ] - @data[1][:value].force_encoding("UTF-8") if RUBY_VERSION>="1.9" + @data[1][:value].force_encoding("UTF-8") _prepare(@data) - cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new + cgi = CGI.new(:accept_charset=>"UTF-8") assert_equal('file1.html', cgi['file1'].original_filename) end @@ -342,7 +338,7 @@ class CGIMultipartTest < Test::Unit::TestCase {:name=>'foo', :value=>"bar"}, ] _prepare(@data) - cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new + cgi = CGI.new(:accept_charset=>"UTF-8") assert_equal(cgi['foo'], 'bar') assert_equal(cgi['file'].read, 'b'*10134) cgi['file'].close! if cgi['file'].kind_of? Tempfile diff --git a/test/cgi/test_cgi_tag_helper.rb b/test/cgi/test_cgi_tag_helper.rb index c4ea477a12..eb3c20a02e 100644 --- a/test/cgi/test_cgi_tag_helper.rb +++ b/test/cgi/test_cgi_tag_helper.rb @@ -318,13 +318,11 @@ class CGITagHelperTest < Test::Unit::TestCase assert_match(/^bbdd$/,str) assert_match(/^bbdd$/,str) assert_match(/^bbdd$/,str) - assert_match(//,cgi.text_field(:name=>"name",:value=>"value")) if RUBY_VERSION>="1.9" - if RUBY_VERSION>="1.9" - str=cgi.radio_group("foo",["aa","bb"],["cc","dd",false]) - assert_match(/^bbdd$/,str) - assert_match(/^bbdd$/,str) - assert_match(/^bbdd$/,str) - end + assert_match(//,cgi.text_field(:name=>"name",:value=>"value")) + str=cgi.radio_group("foo",["aa","bb"],["cc","dd",false]) + assert_match(/^bbdd$/,str) + assert_match(/^bbdd$/,str) + assert_match(/^bbdd$/,str) end =begin -- cgit v1.2.3