[#42735] [Ruby 1.9-Feature#4147][Open] Array#sample で重みを指定したい — Yoji Ojima <redmine@...>

Feature #4147: Array#sample で重みを指定したい

52 messages 2010/12/10
[#42791] [Ruby 1.9-Feature#4147][Assigned] Array#sample で重みを指定したい — Shyouhei Urabe <redmine@...> 2010/12/18

チケット #4147 が更新されました。 (by Shyouhei Urabe)

[#42800] Re: [Ruby 1.9-Feature#4147][Assigned] Array#sample で重みを指定したい — Masaya TARUI <tarui@...> 2010/12/19

> じゃあ反対ないので実装はともかく、この仕様は基本入れる方向で考えましょう。反対の人は意思表示お早めに。

[#42763] [Ruby 1.9-Bug#4159][Open] test_block_variables(TestRipper::ParserEvents) が失敗する — Kouhei Yanagita <redmine@...>

Bug #4159: test_block_variables(TestRipper::ParserEvents) が失敗する

8 messages 2010/12/14

[#42894] [Ruby 1.8-Feature#4207][Open] これから「1.8.8」の話をしよう -- 1.8がこの先生きのこるには — Shyouhei Urabe <redmine@...>

Feature #4207: これから「1.8.8」の話をしよう -- 1.8がこの先生きのこるには

24 messages 2010/12/26
[#42935] Re: [Ruby 1.8-Feature#4207][Open] これから「1.8.8」の話をしよう -- 1.8がこの先生きのこるには — Kenta Murata <muraken@...> 2011/01/04

むらたです。

[#42936] Re: [Ruby 1.8-Feature#4207][Open] これから「1.8.8」の話をしよう -- 1.8がこの先生きのこるには — Kenta Murata <muraken@...> 2011/01/05

むらたです。

[ruby-dev:42672] [Ruby 1.9-Bug#4110][Open] ホスト名の先頭が数字であるとき、WEBrickのテストでErrorが出る

From: Kouhei Yanagita <redmine@...>
Date: 2010-12-02 13:22:07 UTC
List: ruby-dev #42672
Bug #4110: ホスト名の先頭が数字であるとき、WEBrickのテストでErrorが出る
http://redmine.ruby-lang.org/issues/show/4110

起票者: Kouhei Yanagita
ステータス: Open, 優先度: Normal
ruby -v: ruby 1.9.3dev (2010-12-02 trunk 30021) [x86_64-linux]

ホスト名の先頭が数字であるような環境において、WEBrickのテストでErrorが出ます。

これは、WEBrick::HTTPRequest#parse_uriの中においてURI#host=でホスト名を設定する際、
先頭が数字であるような(ドットを含まない)ホスト名は許されないので例外が発生しているためです。

ひとまず、設定の:ServerNameを'localhost'にしてみたらテストは通りました。


$ ~/local/ruby-trunk/bin/ruby -v test/webrick/test_filehandler.rb 
ruby 1.9.3dev (2010-12-02 trunk 30021) [x86_64-linux]
test/webrick/test_filehandler.rb:187: warning: assigned but unused variable - this_file
test/webrick/test_filehandler.rb:202: warning: assigned but unused variable - this_file
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:623: warning: assigned but unused variable - ac
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:624: warning: assigned but unused variable - tc
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - canon
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - sw
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - cn
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:446: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:13536: warning: assigned but unused variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:447: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:13536: warning: assigned but unused variable - s
Run options: 

# Running tests:

..E....

Finished tests in 0.657798s, 10.6416 tests/s, 83.6123 assertions/s.

  1) Error:
test_make_partial_content(WEBrick::TestFileHandler):
WEBrick::HTTPStatus::BadRequest: bad URI `/'.
    test/webrick/test_filehandler.rb:35:in `make_range_response'
    test/webrick/test_filehandler.rb:47:in `test_make_partial_content'

7 tests, 55 assertions, 0 failures, 1 errors, 0 skips


$ ~/local/ruby-trunk/bin/ruby -v test/webrick/test_httprequest.rb 
ruby 1.9.3dev (2010-12-02 trunk 30021) [x86_64-linux]
test/webrick/test_httprequest.rb:321: warning: ambiguous first argument; put parentheses or even spaces
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:623: warning: assigned but unused variable - ac
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:624: warning: assigned but unused variable - tc
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - canon
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - sw
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - cn
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:446: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:14640: warning: assigned but unused variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:447: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:14640: warning: assigned but unused variable - s
Run options: 

# Running tests:

..EE.EEE.E....

Finished tests in 0.015776s, 887.4239 tests/s, 3866.6329 assertions/s.

  1) Error:
test_continue_not_sent(TestWEBrickHTTPRequest):
WEBrick::HTTPStatus::BadRequest: bad URI `/path'.
    test/webrick/test_httprequest.rb:332:in `test_continue_not_sent'

  2) Error:
test_continue_sent(TestWEBrickHTTPRequest):
WEBrick::HTTPStatus::BadRequest: bad URI `/path'.
    test/webrick/test_httprequest.rb:316:in `test_continue_sent'

  3) Error:
test_parse_09(TestWEBrickHTTPRequest):
WEBrick::HTTPStatus::BadRequest: bad URI `/'.
    test/webrick/test_httprequest.rb:12:in `test_parse_09'

  4) Error:
test_parse_10(TestWEBrickHTTPRequest):
WEBrick::HTTPStatus::BadRequest: bad URI `/'.
    test/webrick/test_httprequest.rb:29:in `test_parse_10'

  5) Error:
test_parse_11(TestWEBrickHTTPRequest):
WEBrick::HTTPStatus::BadRequest: bad URI `/path'.
    test/webrick/test_httprequest.rb:46:in `test_parse_11'

  6) Error:
test_parse_header2(TestWEBrickHTTPRequest):
WEBrick::HTTPStatus::BadRequest: bad URI `/foo/bar/../baz?q=a'.
    test/webrick/test_httprequest.rb:117:in `test_parse_header2'

14 tests, 61 assertions, 0 failures, 6 errors, 0 skips


----------------------------------------
http://redmine.ruby-lang.org

Attachments (1)

fix_webrick_test.diff (9.26 KB, text/x-diff)
Index: test/webrick/test_httprequest.rb
===================================================================
--- test/webrick/test_httprequest.rb	(revision 30049)
+++ test/webrick/test_httprequest.rb	(working copy)
@@ -3,17 +3,19 @@
 require "test/unit"
 
 class TestWEBrickHTTPRequest < Test::Unit::TestCase
+  HTTP_CONFIG = WEBrick::Config::HTTP.merge(:ServerName => 'localhost')
+
   def test_parse_09
     msg = <<-_end_of_message_
       GET /
       foobar    # HTTP/0.9 request don't have header nor entity body.
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal("GET", req.request_method)
     assert_equal("/", req.unparsed_uri)
     assert_equal(WEBrick::HTTPVersion.new("0.9"), req.http_version)
-    assert_equal(WEBrick::Config::HTTP[:ServerName], req.host)
+    assert_equal(HTTP_CONFIG[:ServerName], req.host)
     assert_equal(80, req.port)
     assert_equal(false, req.keep_alive?)
     assert_equal(nil, req.body)
@@ -25,12 +27,12 @@
       GET / HTTP/1.0
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal("GET", req.request_method)
     assert_equal("/", req.unparsed_uri)
     assert_equal(WEBrick::HTTPVersion.new("1.0"), req.http_version)
-    assert_equal(WEBrick::Config::HTTP[:ServerName], req.host)
+    assert_equal(HTTP_CONFIG[:ServerName], req.host)
     assert_equal(80, req.port)
     assert_equal(false, req.keep_alive?)
     assert_equal(nil, req.body)
@@ -42,14 +44,14 @@
       GET /path HTTP/1.1
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal("GET", req.request_method)
     assert_equal("/path", req.unparsed_uri)
     assert_equal("", req.script_name)
     assert_equal("/path", req.path_info)
     assert_equal(WEBrick::HTTPVersion.new("1.1"), req.http_version)
-    assert_equal(WEBrick::Config::HTTP[:ServerName], req.host)
+    assert_equal(HTTP_CONFIG[:ServerName], req.host)
     assert_equal(80, req.port)
     assert_equal(true, req.keep_alive?)
     assert_equal(nil, req.body)
@@ -60,7 +62,7 @@
     msg = <<-_end_of_message_
       GET /#{"a"*2084} HTTP/1.1
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     assert_raise(WEBrick::HTTPStatus::RequestURITooLarge){
       req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     }
@@ -83,7 +85,7 @@
 
       foobar
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal(
       URI.parse("http://test.ruby-lang.org:8080/path"), req.request_uri)
@@ -113,7 +115,7 @@
 
       hogehoge
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal("POST", req.request_method)
     assert_equal("/foo/baz", req.path)
@@ -130,7 +132,7 @@
       Host: test.ruby-lang.org
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal(URI.parse("http://test.ruby-lang.org/path"), req.request_uri)
     assert_equal("test.ruby-lang.org", req.host)
@@ -141,7 +143,7 @@
       Host: 192.168.1.1
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal(URI.parse("http://192.168.1.1/path"), req.request_uri)
     assert_equal("192.168.1.1", req.host)
@@ -152,7 +154,7 @@
       Host: [fe80::208:dff:feef:98c7]
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal(URI.parse("http://[fe80::208:dff:feef:98c7]/path"),
                  req.request_uri)
@@ -164,7 +166,7 @@
       Host: 192.168.1.1:8080
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal(URI.parse("http://192.168.1.1:8080/path"), req.request_uri)
     assert_equal("192.168.1.1", req.host)
@@ -175,7 +177,7 @@
       Host: [fe80::208:dff:feef:98c7]:8080
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     assert_equal(URI.parse("http://[fe80::208:dff:feef:98c7]:8080/path"),
                  req.request_uri)
@@ -190,7 +192,7 @@
       Host: test.ruby-lang.org:8080
 
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     query = req.query
     assert_equal("1", query["foo"])
@@ -210,7 +212,7 @@
 
       #{param}
     _end_of_message_
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
     query = req.query
     assert_equal("1", query["foo"])
@@ -236,7 +238,7 @@
       end
     }
     msg << "0" << crlf
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg))
     assert_equal(File.read(__FILE__), req.body)
   end
@@ -253,7 +255,7 @@
 
     _end_of_message_
     msg.gsub!(/^ {6}/, "")
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg))
     assert_equal("server.example.com", req.server_name)
     assert_equal("http://forward.example.com/foo", req.request_uri.to_s)
@@ -273,7 +275,7 @@
 
     _end_of_message_
     msg.gsub!(/^ {6}/, "")
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg))
     assert_equal("server.example.com", req.server_name)
     assert_equal("http://forward.example.com:8080/foo", req.request_uri.to_s)
@@ -295,7 +297,7 @@
 
     _end_of_message_
     msg.gsub!(/^ {6}/, "")
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg))
     assert_equal("server.example.com", req.server_name)
     assert_equal("https://forward.example.com/foo", req.request_uri.to_s)
@@ -312,7 +314,7 @@
       
     _end_of_message_
     msg.gsub!(/^ {6}/, "")
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg))
     assert req['expect']
     l = msg.size
@@ -328,7 +330,7 @@
       
     _end_of_message_
     msg.gsub!(/^ {6}/, "")
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(StringIO.new(msg))
     assert !req['expect']
     l = msg.size
@@ -346,7 +348,7 @@
       #{param}
     _end_of_message_
     assert_raise(WEBrick::HTTPStatus::LengthRequired){
-      req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+      req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
       req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
       req.body
     }
@@ -359,7 +361,7 @@
       body is too short.
     _end_of_message_
     assert_raise(WEBrick::HTTPStatus::BadRequest){
-      req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+      req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
       req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
       req.body
     }
@@ -372,7 +374,7 @@
       body is too short.
     _end_of_message_
     assert_raise(WEBrick::HTTPStatus::NotImplemented){
-      req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+      req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
       req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
       req.body
     }
Index: test/webrick/test_filehandler.rb
===================================================================
--- test/webrick/test_filehandler.rb	(revision 30049)
+++ test/webrick/test_filehandler.rb	(working copy)
@@ -4,9 +4,11 @@
 require "stringio"
 
 class WEBrick::TestFileHandler < Test::Unit::TestCase
+  HTTP_CONFIG = WEBrick::Config::HTTP.merge(:ServerName => 'localhost')
+
   def default_file_handler(filename)
     klass = WEBrick::HTTPServlet::DefaultFileHandler
-    klass.new(WEBrick::Config::HTTP, filename)
+    klass.new(HTTP_CONFIG, filename)
   end
 
   def windows?
@@ -31,9 +33,9 @@
   end
 
   def make_range_response(file, range_spec)
-    req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+    req = WEBrick::HTTPRequest.new(HTTP_CONFIG)
     req.parse(make_range_request(range_spec))
-    res = WEBrick::HTTPResponse.new(WEBrick::Config::HTTP)
+    res = WEBrick::HTTPResponse.new(HTTP_CONFIG)
     size = File.size(file)
     handler = default_file_handler(file)
     handler.make_partial_content(req, res, file, size)

In This Thread

Prev Next