ruby-changes:35028
From: hsbt <ko1@a...>
Date: Sat, 9 Aug 2014 10:19:32 +0900 (JST)
Subject: [ruby-changes:35028] hsbt:r47110 (trunk): * test/cgi/test_cgi_core.rb: removed obsoleted condition for Ruby 1.8.
hsbt 2014-08-09 10:19:18 +0900 (Sat, 09 Aug 2014) New Revision: 47110 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47110 Log: * 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. Modified files: trunk/ChangeLog trunk/test/cgi/test_cgi_core.rb trunk/test/cgi/test_cgi_header.rb trunk/test/cgi/test_cgi_multipart.rb trunk/test/cgi/test_cgi_tag_helper.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 47109) +++ ChangeLog (revision 47110) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Aug 9 10:18:00 2014 SHIBATA Hiroshi <shibata.hiroshi@g...> + + * 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. + Sat Aug 9 00:34:37 2014 Masaki Suketa <masaki.suketa@n...> * ext/win32ole/win32ole.c: separate WIN32OLE_TYPE src from win32ole.c. Index: test/cgi/test_cgi_multipart.rb =================================================================== --- test/cgi/test_cgi_multipart.rb (revision 47109) +++ test/cgi/test_cgi_multipart.rb (revision 47110) @@ -152,24 +152,20 @@ class CGIMultipartTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L152 _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::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L297 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::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L308 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::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L324 {: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::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L338 {: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 Index: test/cgi/test_cgi_core.rb =================================================================== --- test/cgi/test_cgi_core.rb (revision 47109) +++ test/cgi/test_cgi_core.rb (revision 47110) @@ -31,7 +31,7 @@ class CGICoreTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_core.rb#L31 } 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 https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_core.rb#L48 ## 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 https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_core.rb#L178 } 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 Index: test/cgi/test_cgi_header.rb =================================================================== --- test/cgi/test_cgi_header.rb (revision 47109) +++ test/cgi/test_cgi_header.rb (revision 47110) @@ -71,12 +71,8 @@ class CGIHeaderTest < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_header.rb#L71 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 Index: test/cgi/test_cgi_tag_helper.rb =================================================================== --- test/cgi/test_cgi_tag_helper.rb (revision 47109) +++ test/cgi/test_cgi_tag_helper.rb (revision 47110) @@ -318,13 +318,11 @@ class CGITagHelperTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_tag_helper.rb#L318 assert_match(/^<INPUT .*TYPE="checkbox".*>bb<INPUT .*TYPE="checkbox".*>dd$/,str) assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str) assert_match(/^<INPUT .*>bb<INPUT .*CHECKED.*>dd$/,str) - assert_match(/<INPUT .*TYPE="text".*>/,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(/^<INPUT .*VALUE="aa".*>bb<INPUT .*VALUE="cc".*>dd$/,str) - assert_match(/^<INPUT .*TYPE="radio".*>bb<INPUT .*TYPE="radio".*>dd$/,str) - assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str) - end + assert_match(/<INPUT .*TYPE="text".*>/,cgi.text_field(:name=>"name",:value=>"value")) + str=cgi.radio_group("foo",["aa","bb"],["cc","dd",false]) + assert_match(/^<INPUT .*VALUE="aa".*>bb<INPUT .*VALUE="cc".*>dd$/,str) + assert_match(/^<INPUT .*TYPE="radio".*>bb<INPUT .*TYPE="radio".*>dd$/,str) + assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str) end =begin -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/