Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update test-mri to CRuby1.9.2-p318

  • Loading branch information...
commit 210fe556124f35bb3b6bd058f954ae291548a834 1 parent 320c12b
@Watson1978 Watson1978 authored
View
20 test-mri/bootstraptest/test_fork.rb
@@ -47,3 +47,23 @@
:ok
end
}, '[ruby-core:28924]'
+
+assert_equal '[1, 2]', %q{
+ a = []
+ trap(:INT) { a.push(1) }
+ trap(:TERM) { a.push(2) }
+ pid = $$
+ begin
+ fork do
+ sleep 0.5
+ Process.kill(:INT, pid)
+ Process.kill(:TERM, pid)
+ end
+
+ sleep 1
+ a.sort
+ rescue NotImplementedError
+ [1, 2]
+ end
+}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]'
+
View
58 test-mri/bootstraptest/test_thread.rb
@@ -21,8 +21,8 @@
}
v
}
-assert_equal %q{50}, %q{
- 50.times{|e|
+assert_equal %q{5000}, %q{
+ 5000.times{|e|
(1..2).map{
Thread.new{
}
@@ -31,8 +31,8 @@
}
}
}
-assert_equal %q{50}, %q{
- 50.times{|e|
+assert_equal %q{5000}, %q{
+ 5000.times{|e|
(1..2).map{
Thread.new{
}
@@ -41,8 +41,8 @@
}
}
}
-assert_equal %q{50}, %q{
- 50.times{
+assert_equal %q{5000}, %q{
+ 5000.times{
t = Thread.new{}
while t.alive?
Thread.pass
@@ -286,34 +286,34 @@ def m
at_exit { Fiber.new{}.resume }
}
-# assert_normal_exit %q{
-# g = enum_for(:local_variables)
-# loop { g.next }
-# }, '[ruby-dev:34128]'
+assert_normal_exit %q{
+ g = enum_for(:local_variables)
+ loop { g.next }
+}, '[ruby-dev:34128]'
-# assert_normal_exit %q{
-# g = enum_for(:block_given?)
-# loop { g.next }
-# }, '[ruby-dev:34128]'
+assert_normal_exit %q{
+ g = enum_for(:block_given?)
+ loop { g.next }
+}, '[ruby-dev:34128]'
-# assert_normal_exit %q{
-# g = enum_for(:binding)
-# loop { g.next }
-# }, '[ruby-dev:34128]'
+assert_normal_exit %q{
+ g = enum_for(:binding)
+ loop { g.next }
+}, '[ruby-dev:34128]'
-# assert_normal_exit %q{
-# g = "abc".enum_for(:scan, /./)
-# loop { g.next }
-# }, '[ruby-dev:34128]'
+assert_normal_exit %q{
+ g = "abc".enum_for(:scan, /./)
+ loop { g.next }
+}, '[ruby-dev:34128]'
-# assert_normal_exit %q{
-# g = Module.enum_for(:new)
-# loop { g.next }
-# }, '[ruby-dev:34128]'
+assert_normal_exit %q{
+ g = Module.enum_for(:new)
+ loop { g.next }
+}, '[ruby-dev:34128]'
-# assert_normal_exit %q{
-# Fiber.new(&Object.method(:class_eval)).resume("foo")
-# }, '[ruby-dev:34128]'
+assert_normal_exit %q{
+ Fiber.new(&Object.method(:class_eval)).resume("foo")
+}, '[ruby-dev:34128]'
assert_normal_exit %q{
Thread.new("foo", &Object.method(:class_eval)).join
View
2  test-mri/test/drb/drbtest.rb
@@ -14,7 +14,7 @@ def self.add_service_command(nm)
DRb::ExtServManager.command[nm] = "#{@@ruby} \"#{dir}/#{nm}\""
end
- %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb).each do |nm|
+ %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb ut_eq.rb).each do |nm|
add_service_command(nm)
end
@server = @@server = DRb::DRbServer.new('druby://localhost:0', @@manager, {})
View
16 test-mri/test/drb/test_drb.rb
@@ -299,3 +299,19 @@ def test_05_too_large_ary
assert_kind_of(StandardError, exception)
end
end
+
+class TestBug4409 < Test::Unit::TestCase
+ def setup
+ @ext = DRbService.ext_service('ut_eq.rb')
+ @there = @ext.front
+ end
+
+ def teardown
+ @ext.stop_service if @ext
+ end
+
+ def test_bug4409
+ foo = @there.foo
+ assert(@there.foo?(foo))
+ end
+end
View
30 test-mri/test/drb/ut_eq.rb
@@ -0,0 +1,30 @@
+require 'drb/drb'
+require 'drb/extserv'
+
+class Foo
+ include DRbUndumped
+end
+
+class Bar
+ include DRbUndumped
+ def initialize
+ @foo = Foo.new
+ end
+ attr_reader :foo
+
+ def foo?(foo)
+ @foo == foo
+ end
+end
+
+if __FILE__ == $0
+ def ARGV.shift
+ it = super()
+ raise "usage: #{$0} <uri> <name>" unless it
+ it
+ end
+
+ DRb.start_service('druby://:0', Bar.new)
+ es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
+ DRb.thread.join
+end
View
6 test-mri/test/etc/test_etc.rb
@@ -38,7 +38,9 @@ def test_getpwuid
def test_getpwnam
passwd = {}
- Etc.passwd {|s| passwd[s.name] ||= s }
+ Etc.passwd do |s|
+ passwd[s.name] ||= s unless /\A\+/ =~ s.name
+ end
passwd.each_value do |s|
assert_equal(s, Etc.getpwnam(s.name))
end
@@ -80,7 +82,7 @@ def test_getgrgid
def test_getgrnam
groups = {}
Etc.group do |s|
- groups[s.name] ||= s
+ groups[s.name] ||= s unless /\A\+/ =~ s.name
end
groups.each_value do |s|
assert_equal(s, Etc.getgrnam(s.name))
View
2  test-mri/test/gdbm/test_gdbm.rb
@@ -83,7 +83,7 @@ def test_s_open_create_new
begin
assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}"))
gdbm.close
- assert_equal(File.stat("#{@tmpdir}/#{@prefix}").mode & 0777, 0666) unless /mswin|mignw/ =~ RUBY_PLATFORM
+ assert_equal(File.stat("#{@tmpdir}/#{@prefix}").mode & 0777, 0666) unless /mswin|mingw/ =~ RUBY_PLATFORM
assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}2", 0644))
gdbm.close
assert_equal(File.stat("#{@tmpdir}/#{@prefix}2").mode & 0777, 0644)
View
71 test-mri/test/openssl/test_ssl.rb
@@ -449,6 +449,62 @@ def test_post_connection_check
}
end
+ DUMMY_SESSION = <<__EOS__
+-----BEGIN SSL SESSION PARAMETERS-----
+MIIDzQIBAQICAwEEAgA5BCAF219w9ZEV8dNA60cpEGOI34hJtIFbf3bkfzSgMyad
+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N7ucY+MUvMqv+R8ZSkHPsnjkBN5ChvZXjrUSZKFVjR4eFVz2V
+jismLEJvIFhQh6pqTroRrOjMfTaM5Lwoytr2FTGobN9rnjIRsXeFQW1HLFbXn7Dh
+8uaQkMwIVVSGRB8T7t6z6WIdWruOjCZ6G5ASI5XoqAHwGezhLodZuvJEfsVyCF9y
+j+RBGfCFrrQbBdnkFI/ztgM=
+-----END SSL SESSION PARAMETERS-----
+__EOS__
+
+ def test_session_time
+ sess = OpenSSL::SSL::Session.new(DUMMY_SESSION)
+ sess.time = (now = Time.now)
+ assert_equal(now.to_i, sess.time.to_i)
+ sess.time = 1
+ assert_equal(1, sess.time.to_i)
+ sess.time = 1.2345
+ assert_equal(1, sess.time.to_i)
+ # Can OpenSSL handle t>2038y correctly? Version?
+ sess.time = 2**31 - 1
+ assert_equal(2**31 - 1, sess.time.to_i)
+ end
+
+ def test_session_timeout
+ sess = OpenSSL::SSL::Session.new(DUMMY_SESSION)
+
+ # it is trivial that this is a wrong feature
+ # but necessary to keep it for compatibility.
+ sess.timeout = (now = Time.now)
+ assert_equal(now.to_i, sess.timeout.to_i)
+
+ sess.timeout = 1
+ assert_equal(1, sess.timeout.to_i)
+ sess.timeout = 1.2345
+ assert_equal(1, sess.timeout.to_i)
+ sess.timeout = 2**31 - 1
+ assert_equal(2**31 - 1, sess.timeout.to_i)
+ end
+
+
def test_client_session
last_session = nil
start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) do |server, port|
@@ -614,6 +670,21 @@ def test_tlsext_hostname
end
end
end
+
+ def test_unset_OP_ALL
+ ctx_proc = Proc.new { |ctx|
+ ctx.options = OpenSSL::SSL::OP_ALL & ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS
+ }
+ start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc){|server, port|
+ sock = TCPSocket.new("127.0.0.1", port)
+ ssl = OpenSSL::SSL::SSLSocket.new(sock)
+ ssl.sync_close = true
+ ssl.connect
+ ssl.puts('hello')
+ assert_equal("hello\n", ssl.gets)
+ ssl.close
+ }
+ end
end
end
View
2  test-mri/test/optparse/test_optarg.rb
@@ -5,6 +5,8 @@ def setup
super
@opt.def_option("-x[VAL]") {|x| @flag = x}
@opt.def_option("--option[=VAL]") {|x| @flag = x}
+ @opt.def_option("--regexp[=REGEXP]", Regexp) {|x| @reopt = x}
+ @reopt = nil
end
def test_short
View
17 test-mri/test/optparse/test_optparse.rb
@@ -6,10 +6,17 @@ def setup
@opt = OptionParser.new
@flag = self.class # cannot set by option
end
+
+ class DummyOutput < String
+ alias write <<
+ end
def no_error(*args)
+ $stderr, stderr = DummyOutput.new, $stderr
assert_nothing_raised(*args) {return yield}
ensure
+ stderr, $stderr = $stderr, stderr
$!.backtrace.delete_if {|e| /\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}/o =~ e} if $!
+ assert_empty(stderr)
end
def test_permute
@@ -45,4 +52,14 @@ def test_order
assert_equal(%w"foo -- --help bar", no_error {@opt.order!(%w"foo -- --help bar")})
assert_equal(self.class, @flag)
end
+
+ def test_regexp
+ return unless defined?(@reopt)
+ assert_equal(%w"", no_error {@opt.parse!(%w"--regexp=/foo/")})
+ assert_equal(/foo/, @reopt)
+ assert_equal(%w"", no_error {@opt.parse!(%w"--regexp=/foo/i")})
+ assert_equal(/foo/i, @reopt)
+ assert_equal(%w"", no_error {@opt.parse!(%w"--regexp=/foo/n")})
+ assert_equal(/foo/n, @reopt)
+ end
end
View
3  test-mri/test/optparse/test_placearg.rb
@@ -6,7 +6,10 @@ def setup
@opt.def_option("-x [VAL]") {|x| @flag = x}
@opt.def_option("--option [VAL]") {|x| @flag = x}
@opt.def_option("-T [level]", /^[0-4]$/, Integer) {|x| @topt = x}
+ @topt = nil
@opt.def_option("-n") {}
+ @opt.def_option("--regexp [REGEXP]", Regexp) {|x| @reopt = x}
+ @reopt = nil
end
def test_short
View
2  test-mri/test/optparse/test_reqarg.rb
@@ -7,6 +7,8 @@ def setup
super
@opt.def_option("-xVAL") {|x| @flag = x}
@opt.def_option("--option=VAL") {|x| @flag = x}
+ @opt.def_option("--regexp=REGEXP", Regexp) {|x| @reopt = x}
+ @reopt = nil
end
end
class Def2 < TestOptionParser
View
2  test-mri/test/ruby/test_enumerator.rb
@@ -43,7 +43,7 @@ def test_loop
}
end
- def test_nested_itaration
+ def test_nested_iteration
def (o = Object.new).each
yield :ok1
yield [:ok2, :x].each.next
View
13 test-mri/test/ruby/test_method.rb
@@ -211,6 +211,19 @@ def o.foo(c)
end
end
+ def test_super_in_proc_from_define_method
+ c1 = Class.new {
+ def m
+ :m1
+ end
+ }
+ c2 = Class.new(c1) { define_method(:m) { Proc.new { super() } } }
+ # c2.new.m.call should return :m1, but currently it raise NoMethodError.
+ # see [Bug #4881] and [Bug #3136]
+ assert_raise(NoMethodError) {
+ c2.new.m.call
+ }
+ end
def test_clone
o = Object.new
def o.foo; :foo; end
View
37 test-mri/test/ruby/test_module.rb
@@ -451,7 +451,7 @@ def initialize
assert_equal(false, o.respond_to?(:bar=))
end
- def test_const_get2
+ def test_const_get_evaled
c1 = Class.new
c2 = Class.new(c1)
@@ -481,16 +481,47 @@ def const_missing(x)
assert_raise(NameError) { c1.const_get(:foo) }
end
- def test_const_set2
+ def test_const_set_invalid_name
c1 = Class.new
assert_raise(NameError) { c1.const_set(:foo, :foo) }
end
- def test_const_get3
+ def test_const_get_invalid_name
c1 = Class.new
assert_raise(NameError) { c1.const_defined?(:foo) }
end
+ def test_const_get_no_inherited
+ bug3422 = '[ruby-core:30719]'
+ assert_in_out_err([], <<-INPUT, %w[1 NameError A], [], bug3422)
+ BasicObject::A = 1
+ puts [true, false].map {|inh|
+ begin
+ Object.const_get(:A, inh)
+ rescue NameError => e
+ [e.class, e.name]
+ end
+ }
+ INPUT
+ end
+
+ def test_const_get_inherited
+ bug3423 = '[ruby-core:30720]'
+ assert_in_out_err([], <<-INPUT, %w[NameError A NameError A], [], bug3423)
+ module Foo; A = 1; end
+ class Object; include Foo; end
+ class Bar; include Foo; end
+
+ puts [Object, Bar].map {|klass|
+ begin
+ klass.const_get(:A, false)
+ rescue NameError => e
+ [e.class, e.name]
+ end
+ }
+ INPUT
+ end
+
def test_class_variable_get
c = Class.new
c.class_eval('@@foo = :foo')
View
22 test-mri/test/ruby/test_settracefunc.rb
@@ -354,4 +354,26 @@ def test_thread_trace
assert_equal([], events[:set])
assert_equal([], events[:add])
end
+
+ def test_trace_defined_method
+ events = []
+ eval <<-EOF.gsub(/^.*?: /, "")
+ 1: class FooBar; define_method(:foobar){}; end
+ 2: fb = FooBar.new
+ 3: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
+ 4: events << [event, lineno, mid, klass]
+ 5: })
+ 6: fb.foobar
+ 7: set_trace_func(nil)
+ EOF
+
+ [["c-return", 5, :set_trace_func, Kernel],
+ ["line", 6, __method__, self.class],
+ ["call", 6, :foobar, FooBar],
+ ["return", 6, :foobar, FooBar],
+ ["line", 7, __method__, self.class],
+ ["c-call", 7, :set_trace_func, Kernel]].each{|e|
+ assert_equal(e, events.shift)
+ }
+ end
end
View
22 test-mri/test/webrick/test_httprequest.rb
@@ -303,6 +303,28 @@ def test_forwarded
assert_equal(443, req.port)
assert_equal("234.234.234.234", req.remote_ip)
assert(req.ssl?)
+
+ msg = <<-_end_of_message_
+ GET /foo HTTP/1.1
+ Host: localhost:10080
+ Client-IP: 234.234.234.234
+ X-Forwarded-Proto: https
+ X-Forwarded-For: 192.168.1.10
+ X-Forwarded-Host: forward1.example.com:1234, forward2.example.com:5678
+ X-Forwarded-Server: server1.example.com, server2.example.com
+ X-Requested-With: XMLHttpRequest
+ Connection: Keep-Alive
+
+ _end_of_message_
+ msg.gsub!(/^ {6}/, "")
+ req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+ req.parse(StringIO.new(msg))
+ assert_equal("server1.example.com", req.server_name)
+ assert_equal("https://forward1.example.com:1234/foo", req.request_uri.to_s)
+ assert_equal("forward1.example.com", req.host)
+ assert_equal(1234, req.port)
+ assert_equal("234.234.234.234", req.remote_ip)
+ assert(req.ssl?)
end
def test_bad_messages
View
2  test-mri/test/webrick/test_httputils.rb
@@ -60,7 +60,7 @@ def test_split_header_value
end
def test_escape
- assert_equal("/abcdefghijklmnopqrstuvwxyz", escape("/abcdefghijklmnopqrstuvwxyz"))
+ assert_equal("/abcdefghijklmnopqrstuvwxyz", escape("/abcdefghijklmnopqrstuvwxyz")) # MACRUBY
assert_equal("/foo/bar", escape("/foo/bar"))
assert_equal("/~foo/bar", escape("/~foo/bar"))
assert_equal("/~foo%20bar", escape("/~foo bar"))

0 comments on commit 210fe55

Please sign in to comment.
Something went wrong with that request. Please try again.