summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--test/cgi/test_cgi_core.rb65
-rw-r--r--test/cgi/test_cgi_header.rb8
-rw-r--r--test/cgi/test_cgi_multipart.rb28
-rw-r--r--test/cgi/test_cgi_tag_helper.rb12
5 files changed, 28 insertions, 92 deletions
diff --git a/ChangeLog b/ChangeLog
index 73931e44819..b67590f7e87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Aug 9 10:18:00 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
+
+ * 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@nifty.ne.jp>
* ext/win32ole/win32ole.c: separate WIN32OLE_TYPE src from win32ole.c.
diff --git a/test/cgi/test_cgi_core.rb b/test/cgi/test_cgi_core.rb
index 123caf7acda..274d088f0f6 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 c6306eb0ff7..90223011533 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 989ac7aba89..806adbd013b 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 c4ea477a12f..eb3c20a02e2 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(/^<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