[#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: =E3=83=9B=E3=82=B9=E3=83=88=E5=90=8D=E3=81=AE=E5=85=88=E9=A0=AD=
=E3=81=8C=E6=95=B0=E5=AD=97=E3=81=A7=E3=81=82=E3=82=8B=E3=81=A8=E3=81=8D=E3=
=80=81WEBrick=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7Error=E3=81=8C=E5=
=87=BA=E3=82=8B
http://redmine.ruby-lang.org/issues/show/4110

=E8=B5=B7=E7=A5=A8=E8=80=85: Kouhei Yanagita
=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF=E3=82=B9: Open, =E5=84=AA=E5=85=88=E5=
=BA=A6: Normal
ruby -v: ruby 1.9.3dev (2010-12-02 trunk 30021) [x86_64-linux]

=E3=83=9B=E3=82=B9=E3=83=88=E5=90=8D=E3=81=AE=E5=85=88=E9=A0=AD=E3=81=8C=E6=
=95=B0=E5=AD=97=E3=81=A7=E3=81=82=E3=82=8B=E3=82=88=E3=81=86=E3=81=AA=E7=92=
=B0=E5=A2=83=E3=81=AB=E3=81=8A=E3=81=84=E3=81=A6=E3=80=81WEBrick=E3=81=AE=
=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7Error=E3=81=8C=E5=87=BA=E3=81=BE=E3=81=
=99=E3=80=82

=E3=81=93=E3=82=8C=E3=81=AF=E3=80=81WEBrick::HTTPRequest#parse_uri=E3=81=AE=
=E4=B8=AD=E3=81=AB=E3=81=8A=E3=81=84=E3=81=A6URI#host=3D=E3=81=A7=E3=83=9B=
=E3=82=B9=E3=83=88=E5=90=8D=E3=82=92=E8=A8=AD=E5=AE=9A=E3=81=99=E3=82=8B=E9=
=9A=9B=E3=80=81
=E5=85=88=E9=A0=AD=E3=81=8C=E6=95=B0=E5=AD=97=E3=81=A7=E3=81=82=E3=82=8B=E3=
=82=88=E3=81=86=E3=81=AA(=E3=83=89=E3=83=83=E3=83=88=E3=82=92=E5=90=AB=E3=
=81=BE=E3=81=AA=E3=81=84)=E3=83=9B=E3=82=B9=E3=83=88=E5=90=8D=E3=81=AF=E8=
=A8=B1=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E3=81=AE=E3=81=A7=E4=BE=8B=E5=A4=
=96=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E3=81=9F=
=E3=82=81=E3=81=A7=E3=81=99=E3=80=82

=E3=81=B2=E3=81=A8=E3=81=BE=E3=81=9A=E3=80=81=E8=A8=AD=E5=AE=9A=E3=81=AE:=
ServerName=E3=82=92'localhost'=E3=81=AB=E3=81=97=E3=81=A6=E3=81=BF=E3=81=9F=
=E3=82=89=E3=83=86=E3=82=B9=E3=83=88=E3=81=AF=E9=80=9A=E3=82=8A=E3=81=BE=E3=
=81=97=E3=81=9F=E3=80=82


$ ~/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 variab=
le - this_file
test/webrick/test_filehandler.rb:202: warning: assigned but unused variab=
le - this_file
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:623: warnin=
g: assigned but unused variable - ac
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:624: warnin=
g: assigned but unused variable - tc
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: as=
signed but unused variable - canon
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: as=
signed but unused variable - sw
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: as=
signed but unused variable - cn
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:446: warning: sh=
adowing 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: sh=
adowing 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: warnin=
g: assigned but unused variable - ac
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:624: warnin=
g: assigned but unused variable - tc
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: as=
signed but unused variable - canon
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: as=
signed but unused variable - sw
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: as=
signed but unused variable - cn
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:446: warning: sh=
adowing 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: sh=
adowing 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=3Da'.
    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