[macruby-changes] [5235] MacRuby/trunk/test/test-mri/test

source_changes at macosforge.org source_changes at macosforge.org
Sat Feb 19 03:27:27 PST 2011


Revision: 5235
          http://trac.macosforge.org/projects/ruby/changeset/5235
Author:   watson1978 at gmail.com
Date:     2011-02-19 03:27:24 -0800 (Sat, 19 Feb 2011)
Log Message:
-----------
Updated the UnitTest with CRuby 1.9.2 p180.

Modified Paths:
--------------
    MacRuby/trunk/test/test-mri/test/csv/test_encodings.rb
    MacRuby/trunk/test/test-mri/test/fiddle/test_fiddle.rb
    MacRuby/trunk/test/test-mri/test/minitest/test_mini_mock.rb
    MacRuby/trunk/test/test-mri/test/minitest/test_mini_test.rb
    MacRuby/trunk/test/test-mri/test/net/http/test_http.rb
    MacRuby/trunk/test/test-mri/test/net/http/test_https.rb
    MacRuby/trunk/test/test-mri/test/net/imap/test_imap.rb
    MacRuby/trunk/test/test-mri/test/net/smtp/test_ssl_socket.rb
    MacRuby/trunk/test/test-mri/test/psych/test_coder.rb
    MacRuby/trunk/test/test-mri/test/psych/test_json_tree.rb
    MacRuby/trunk/test/test-mri/test/psych/test_parser.rb
    MacRuby/trunk/test/test-mri/test/ripper/dummyparser.rb
    MacRuby/trunk/test/test-mri/test/ripper/test_parser_events.rb
    MacRuby/trunk/test/test-mri/test/ruby/test_argf.rb
    MacRuby/trunk/test/test-mri/test/ruby/test_array.rb
    MacRuby/trunk/test/test-mri/test/ruby/test_float.rb
    MacRuby/trunk/test/test-mri/test/ruby/test_io_m17n.rb
    MacRuby/trunk/test/test-mri/test/ruby/test_thread.rb
    MacRuby/trunk/test/test-mri/test/ruby/test_time.rb
    MacRuby/trunk/test/test-mri/test/stringio/test_stringio.rb

Added Paths:
-----------
    MacRuby/trunk/test/test-mri/test/-ext-/string/
    MacRuby/trunk/test/test-mri/test/-ext-/string/test_cstr.rb

Added: MacRuby/trunk/test/test-mri/test/-ext-/string/test_cstr.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/-ext-/string/test_cstr.rb	                        (rev 0)
+++ MacRuby/trunk/test/test-mri/test/-ext-/string/test_cstr.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -0,0 +1,17 @@
+require 'test/unit'
+require "-test-/string/string"
+
+class Test_StringCStr < Test::Unit::TestCase
+  Bug4319 = '[ruby-dev:43094]'
+
+  def test_embed
+    s = Bug::String.new("abcdef")
+    s.set_len(3)
+    assert_equal(0, s.cstr_term, Bug4319)
+  end
+
+  def test_long
+    s = Bug::String.new("abcdef")*100000
+    assert_equal(0, s.cstr_term, Bug4319)
+  end
+end

Modified: MacRuby/trunk/test/test-mri/test/csv/test_encodings.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/csv/test_encodings.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/csv/test_encodings.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -13,11 +13,14 @@
 
 class TestEncodings < Test::Unit::TestCase
   def setup
-    @temp_csv_path = File.join(File.dirname(__FILE__), "temp.csv")
+    require 'tempfile'
+    @temp_csv_file = Tempfile.new(%w"test_csv. .csv")
+    @temp_csv_path = @temp_csv_file.path
+    @temp_csv_file.close
   end
 
   def teardown
-    File.unlink(@temp_csv_path) if File.exist? @temp_csv_path
+    @temp_csv_file.close!
   end
 
   ########################################

Modified: MacRuby/trunk/test/test-mri/test/fiddle/test_fiddle.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/fiddle/test_fiddle.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/fiddle/test_fiddle.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -16,4 +16,14 @@
       assert_equal(DL.const_get(name), Fiddle.const_get(name))
     end
   end
+
+  def test_windows_constant
+    require 'rbconfig'
+    if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
+      assert Fiddle::WINDOWS, "Fiddle::WINDOWS should be 'true' on Windows platforms"
+    else
+      refute Fiddle::WINDOWS, "Fiddle::WINDOWS should be 'false' on non-Windows platforms"
+    end
+  end
+
 end

Modified: MacRuby/trunk/test/test-mri/test/minitest/test_mini_mock.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/minitest/test_mini_mock.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/minitest/test_mini_mock.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -75,6 +75,12 @@
     util_verify_bad
   end
 
+  def test_no_method_error_on_unexpected_methods
+    assert_raises NoMethodError do
+      @mock.bar
+    end
+  end
+
   def util_verify_bad
     assert_raises MockExpectationError do
       @mock.verify

Modified: MacRuby/trunk/test/test-mri/test/minitest/test_mini_test.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/minitest/test_mini_test.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/minitest/test_mini_test.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -609,6 +609,26 @@
     end
   end
 
+  ##
+  # *sigh* This is quite an odd scenario, but it is from real (albeit
+  # ugly) test code in ruby-core:
+  #
+  # http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29259
+
+  def test_assert_raises_skip
+    @assertion_count = 0
+
+    util_assert_triggered "skipped", MiniTest::Skip do
+      @tc.assert_raises ArgumentError do
+        begin
+          raise "blah"
+        rescue
+          skip "skipped"
+        end
+      end
+    end
+  end
+
   def test_assert_raises_module
     @tc.assert_raises M do
       raise E

Modified: MacRuby/trunk/test/test-mri/test/net/http/test_http.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/net/http/test_http.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/net/http/test_http.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -1,4 +1,4 @@
-# $Id: test_http.rb 27605 2010-05-03 23:42:26Z mame $
+# $Id: test_http.rb 30571 2011-01-16 12:35:11Z yugui $
 
 require 'test/unit'
 require 'net/http'
@@ -45,6 +45,10 @@
     assert_equal $test_net_http_data, body
     assert_equal $test_net_http_data.size, res.body.size
     assert_equal $test_net_http_data, res.body
+
+    assert_nothing_raised {
+      res, body = http.get('/', { 'User-Agent' => 'test' }.freeze)
+    }
   end
 
   def _test_get__iter(http)
@@ -169,6 +173,25 @@
     assert_equal ["a=x1", "a=x2", "b=y"], res.body.split(/[;&]/).sort
   end
 
+  def test_timeout_during_HTTP_session
+    bug4246 = "expected the HTTP session to have timed out but have not. c.f. [ruby-core:34203]"
+
+    # listen for connections... but deliberately do not complete SSL handshake
+    TCPServer.open(0) {|server|
+      port = server.addr[1]
+
+      conn = Net::HTTP.new('localhost', port)
+      conn.read_timeout = 1
+      conn.open_timeout = 1
+
+      th = Thread.new do
+        assert_raise(Timeout::Error) {
+          conn.get('/')
+        }
+      end
+      assert th.join(10), bug4246
+    }
+  end
 end
 
 

Modified: MacRuby/trunk/test/test-mri/test/net/http/test_https.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/net/http/test_https.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/net/http/test_https.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -2,6 +2,7 @@
 begin
   require 'net/https'
   require 'stringio'
+  require 'timeout'
   require File.expand_path("../../openssl/utils", File.dirname(__FILE__))
   require File.expand_path("utils", File.dirname(__FILE__))
 rescue LoadError
@@ -94,4 +95,25 @@
     }
     assert_match(/hostname was not match/, ex.message)
   end
+
+  def test_timeout_during_SSL_handshake
+    bug4246 = "expected the SSL connection to have timed out but have not. [ruby-core:34203]"
+
+    # listen for connections... but deliberately do not complete SSL handshake
+    TCPServer.open(0) {|server|
+      port = server.addr[1]
+
+      conn = Net::HTTP.new('localhost', port)
+      conn.use_ssl = true
+      conn.read_timeout = 1
+      conn.open_timeout = 1
+
+      th = Thread.new do
+        assert_raise(Timeout::Error) {
+          conn.get('/')
+        }
+      end
+      assert th.join(10), bug4246
+    }
+  end
 end if defined?(OpenSSL)

Modified: MacRuby/trunk/test/test-mri/test/net/imap/test_imap.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/net/imap/test_imap.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/net/imap/test_imap.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -425,9 +425,9 @@
     begin
       begin
         imap = yield(port)
-        imap.logout
+        imap.logout if !imap.disconnected?
       ensure
-        imap.disconnect if imap
+        imap.disconnect if imap && !imap.disconnected?
       end
     ensure
       server.close

Modified: MacRuby/trunk/test/test-mri/test/net/smtp/test_ssl_socket.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/net/smtp/test_ssl_socket.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/net/smtp/test_ssl_socket.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -15,6 +15,7 @@
       end
     end
 
+    require 'stringio'
     class SSLSocket < StringIO
       attr_accessor :sync_close, :connected, :closed
 
@@ -87,4 +88,4 @@
       ].join("\r\n") + "\r\n"
     end
   end
-end
+end if defined?(OpenSSL)

Modified: MacRuby/trunk/test/test-mri/test/psych/test_coder.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/psych/test_coder.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/psych/test_coder.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -89,6 +89,10 @@
       end
     end
 
+    def test_json_dump_exclude_tag
+      refute_match('TestCoder::InitApi', Psych.to_json(InitApi.new))
+    end
+
     def test_map_takes_block
       coder = Psych::Coder.new 'foo'
       tag = coder.tag

Modified: MacRuby/trunk/test/test-mri/test/psych/test_json_tree.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/psych/test_json_tree.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/psych/test_json_tree.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -3,11 +3,11 @@
 module Psych
   class TestJSONTree < TestCase
     def test_string
-      assert_match(/(['"])foo\1/, Psych.to_json("foo"))
+      assert_match(/"foo"/, Psych.to_json("foo"))
     end
 
     def test_symbol
-      assert_match(/(['"])foo\1/, Psych.to_json(:foo))
+      assert_match(/"foo"/, Psych.to_json(:foo))
     end
 
     def test_nil
@@ -36,8 +36,8 @@
       json = Psych.to_json(list)
       assert_match(/]$/, json)
       assert_match(/^\[/, json)
-      assert_match(/['"]one['"]/, json)
-      assert_match(/['"]two['"]/, json)
+      assert_match(/"one"/, json)
+      assert_match(/"two"/, json)
     end
   end
 end

Modified: MacRuby/trunk/test/test-mri/test/psych/test_parser.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/psych/test_parser.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/psych/test_parser.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -46,6 +46,21 @@
       end
     end
 
+    # ruby-core:34690
+    def test_exception_line
+      e = assert_raises(Psych::SyntaxError) do
+        @parser.parse(<<-eoyaml)
+# based on "SGML/XML character entity reference" at http://www.bitjungle.com/isoent/
+#
+---
+#DOUBLE LOW-9 QUOTATION MARK
+#requires fontenc:T1
+ldquor: ,,
+        eoyaml
+      end
+      assert_match 'line 6', e.message
+    end
+
     def test_mapping_end
       @parser.parse("---\n!!map { key: value }")
       assert_called :end_mapping

Modified: MacRuby/trunk/test/test-mri/test/ripper/dummyparser.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ripper/dummyparser.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ripper/dummyparser.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -10,7 +10,7 @@
     @children = nodes
   end
 
-  attr_reader :children
+  attr_reader :name, :children
 
   def to_s
     "#{@name}(#{Node.trim_nil(@children).map {|n| n.to_s }.join(',')})"
@@ -47,12 +47,14 @@
 end
 
 class DummyParser < Ripper
-  def hook(name)
+  def hook(*names)
     class << self; self; end.class_eval do
-      define_method(name) do |*a, &b|
-        result = super(*a, &b)
-        yield(*a)
-        result
+      names.each do |name|
+        define_method(name) do |*a, &b|
+          result = super(*a, &b)
+          yield(name, *a)
+          result
+        end
       end
     end
     self

Modified: MacRuby/trunk/test/test-mri/test/ripper/test_parser_events.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ripper/test_parser_events.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ripper/test_parser_events.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -20,7 +20,7 @@
 
   def parse(str, nm = nil, &bl)
     dp = DummyParser.new(str)
-    dp.hook(nm, &bl) if nm
+    dp.hook(*nm, &bl) if nm
     dp.parse.to_s
   end
 
@@ -347,10 +347,10 @@
     assert_equal true, thru_heredoc_beg
     assert_match(/string_content\(\),heredoc\n/, tree, bug1921)
     heredoc = nil
-    parse("<<EOS\nheredoc1\nheredoc2\nEOS\n", :on_string_add) {|n, s| heredoc = s}
+    parse("<<EOS\nheredoc1\nheredoc2\nEOS\n", :on_string_add) {|e, n, s| heredoc = s}
     assert_equal("heredoc1\nheredoc2\n", heredoc, bug1921)
     heredoc = nil
-    parse("<<-EOS\nheredoc1\nheredoc2\n\tEOS\n", :on_string_add) {|n, s| heredoc = s}
+    parse("<<-EOS\nheredoc1\nheredoc2\n\tEOS\n", :on_string_add) {|e, n, s| heredoc = s}
     assert_equal("heredoc1\nheredoc2\n", heredoc, bug1921)
   end
 
@@ -676,6 +676,15 @@
     assert_equal true, thru_opassign
   end
 
+  def test_opassign_error
+    thru_opassign = []
+    events = [:on_opassign, :on_assign_error]
+    parse('a::X ||= c 1', events) {|a,*b|
+      thru_opassign << a
+    }
+    assert_equal events, thru_opassign
+  end
+
   def test_param_error
     thru_param_error = false
     parse('def foo(A) end', :on_param_error) {thru_param_error = true}
@@ -1104,7 +1113,7 @@
 
   def test_unterminated_regexp
     compile_error = false
-    parse('/', :compile_error) {|msg| compile_error = msg}
+    parse('/', :compile_error) {|e, msg| compile_error = msg}
     assert_equal("unterminated regexp meets end of file", compile_error)
   end
 end if ripper_test

Modified: MacRuby/trunk/test/test-mri/test/ruby/test_argf.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ruby/test_argf.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ruby/test_argf.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -694,4 +694,20 @@
       assert_equal([@t1.path, @t2.path, @t3.path].inspect, f.gets.chomp)
     end
   end
+
+  def test_unreadable
+    bug4274 = '[ruby-core:34446]'
+    paths = (1..2).map do
+      t = Tempfile.new("bug4274-")
+      path = t.path
+      t.close!
+      path
+    end
+    argf = ARGF.class.new(*paths)
+    paths.each do |path|
+      e = assert_raise(Errno::ENOENT) {argf.gets}
+      assert_match(/- #{Regexp.quote(path)}\z/, e.message)
+    end
+    assert_nil(argf.gets, bug4274)
+  end
 end

Modified: MacRuby/trunk/test/test-mri/test/ruby/test_array.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ruby/test_array.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ruby/test_array.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -890,6 +890,7 @@
     a = @cls[]
     assert_equal("", a.join)
     assert_equal("", a.join(','))
+    assert_equal(Encoding::US_ASCII, a.join.encoding)
 
     $, = ""
     a = @cls[1, 2]

Modified: MacRuby/trunk/test/test-mri/test/ruby/test_float.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ruby/test_float.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ruby/test_float.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -442,6 +442,18 @@
     assert(Float(o).nan?)
   end
 
+  def test_invalid_str
+    bug4310 = '[ruby-core:34820]'
+    assert_raise(ArgumentError, bug4310) {
+      stress, GC.stress = GC.stress, true
+      begin
+        Float('a'*10000)
+      ensure
+        GC.stress = stress
+      end
+    }
+  end
+
   def test_num2dbl
     assert_raise(TypeError) do
       1.0.step(2.0, "0.5") {}

Modified: MacRuby/trunk/test/test-mri/test/ruby/test_io_m17n.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ruby/test_io_m17n.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ruby/test_io_m17n.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -114,9 +114,29 @@
     }
   end
 
-  def test_open_r_enc_in_opt2
+  def test_open_r_encname_in_opt
     with_tmpdir {
       generate_file('tmp', "")
+      open("tmp", "r", encoding: Encoding::EUC_JP) {|f|
+        assert_equal(Encoding::EUC_JP, f.external_encoding)
+        assert_equal(nil, f.internal_encoding)
+      }
+    }
+  end
+
+  def test_open_r_ext_enc_in_opt
+    with_tmpdir {
+      generate_file('tmp', "")
+      open("tmp", "r", external_encoding: Encoding::EUC_JP) {|f|
+        assert_equal(Encoding::EUC_JP, f.external_encoding)
+        assert_equal(nil, f.internal_encoding)
+      }
+    }
+  end
+
+  def test_open_r_ext_encname_in_opt
+    with_tmpdir {
+      generate_file('tmp', "")
       open("tmp", "r", external_encoding: "euc-jp") {|f|
         assert_equal(Encoding::EUC_JP, f.external_encoding)
         assert_equal(nil, f.internal_encoding)
@@ -127,6 +147,16 @@
   def test_open_r_enc_enc
     with_tmpdir {
       generate_file('tmp', "")
+      open("tmp", "r", external_encoding: Encoding::EUC_JP, internal_encoding: Encoding::UTF_8) {|f|
+        assert_equal(Encoding::EUC_JP, f.external_encoding)
+        assert_equal(Encoding::UTF_8, f.internal_encoding)
+      }
+    }
+  end
+
+  def test_open_r_encname_encname
+    with_tmpdir {
+      generate_file('tmp', "")
       open("tmp", "r:euc-jp:utf-8") {|f|
         assert_equal(Encoding::EUC_JP, f.external_encoding)
         assert_equal(Encoding::UTF_8, f.internal_encoding)
@@ -134,7 +164,7 @@
     }
   end
 
-  def test_open_r_enc_enc_in_opt
+  def test_open_r_encname_encname_in_opt
     with_tmpdir {
       generate_file('tmp', "")
       open("tmp", "r", encoding: "euc-jp:utf-8") {|f|
@@ -144,9 +174,19 @@
     }
   end
 
-  def test_open_r_enc_enc_in_opt2
+  def test_open_r_enc_enc_in_opt
     with_tmpdir {
       generate_file('tmp', "")
+      open("tmp", "r", external_encoding: Encoding::EUC_JP, internal_encoding: Encoding::UTF_8) {|f|
+        assert_equal(Encoding::EUC_JP, f.external_encoding)
+        assert_equal(Encoding::UTF_8, f.internal_encoding)
+      }
+    }
+  end
+
+  def test_open_r_encname_encname_in_opt
+    with_tmpdir {
+      generate_file('tmp', "")
       open("tmp", "r", external_encoding: "euc-jp", internal_encoding: "utf-8") {|f|
         assert_equal(Encoding::EUC_JP, f.external_encoding)
         assert_equal(Encoding::UTF_8, f.internal_encoding)

Modified: MacRuby/trunk/test/test-mri/test/ruby/test_thread.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ruby/test_thread.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ruby/test_thread.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -102,6 +102,119 @@
     assert(locked)
   end
 
+  def test_condvar_wait_and_broadcast
+    nr_threads = 3
+    threads = Array.new
+    mutex = Mutex.new
+    condvar = ConditionVariable.new
+    result = []
+
+    nr_threads.times do |i|
+      threads[i] = Thread.new do
+        mutex.synchronize do
+          result << "C1"
+          condvar.wait mutex
+          result << "C2"
+        end
+      end
+    end
+    sleep 0.1
+    mutex.synchronize do
+      result << "P1"
+      condvar.broadcast
+      result << "P2"
+    end
+    nr_threads.times do |i|
+      threads[i].join
+    end
+
+    assert_equal ["C1", "C1", "C1", "P1", "P2", "C2", "C2", "C2"], result
+  end
+
+#  Hmm.. don't we have a way of catch fatal exception?
+#
+#  def test_cv_wait_deadlock
+#    mutex = Mutex.new
+#    cv = ConditionVariable.new
+#
+#    assert_raises(fatal) {
+#      mutex.lock
+#      cv.wait mutex
+#      mutex.unlock
+#    }
+#  end
+
+  def test_condvar_wait_deadlock_2
+    nr_threads = 3
+    threads = Array.new
+    mutex = Mutex.new
+    condvar = ConditionVariable.new
+
+    nr_threads.times do |i|
+      if (i != 0)
+        mutex.unlock
+      end
+      threads[i] = Thread.new do
+        mutex.synchronize do
+          condvar.wait mutex
+        end
+      end
+      mutex.lock
+    end
+
+    assert_raise(Timeout::Error) do
+      Timeout.timeout(0.1) { condvar.wait mutex }
+    end
+    mutex.unlock rescue
+    threads[i].each.join
+  end
+
+  def test_condvar_timed_wait
+    mutex = Mutex.new
+    condvar = ConditionVariable.new
+    timeout = 0.3
+    locked = false
+
+    t0 = Time.now
+    mutex.synchronize do
+      begin
+        condvar.wait(mutex, timeout)
+      ensure
+        locked = mutex.locked?
+      end
+    end
+    t1 = Time.now
+    t = t1-t0
+
+    assert_block { timeout*0.9 < t && t < timeout*1.1 }
+    assert(locked)
+  end
+
+  def test_condvar_nolock
+    mutex = Mutex.new
+    condvar = ConditionVariable.new
+
+    assert_raise(ThreadError) { condvar.wait(mutex) }
+  end
+
+  def test_condvar_nolock_2
+    mutex = Mutex.new
+    condvar = ConditionVariable.new
+
+    Thread.new do
+      assert_raise(ThreadError) {condvar.wait(mutex)}
+    end.join
+  end
+
+  def test_condvar_nolock_3
+    mutex = Mutex.new
+    condvar = ConditionVariable.new
+
+    Thread.new do
+      assert_raise(ThreadError) {condvar.wait(mutex, 0.1)}
+    end.join
+  end
+
   def test_local_barrier
     dir = File.dirname(__FILE__)
     lbtest = File.join(dir, "lbtest.rb")

Modified: MacRuby/trunk/test/test-mri/test/ruby/test_time.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/ruby/test_time.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/ruby/test_time.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -632,6 +632,9 @@
                  t.strftime("%m/%d/%Y %l:%M:%S.%9N"))
     assert_equal("03/14/1592  6:53:58.97932384",
                  t.strftime("%m/%d/%Y %l:%M:%S.%8N"))
+
+    # [ruby-core:33985]
+    assert_equal("3000000000", Time.at(3000000000).strftime('%s'))
   end
 
   def test_delegate

Modified: MacRuby/trunk/test/test-mri/test/stringio/test_stringio.rb
===================================================================
--- MacRuby/trunk/test/test-mri/test/stringio/test_stringio.rb	2011-02-18 23:15:30 UTC (rev 5234)
+++ MacRuby/trunk/test/test-mri/test/stringio/test_stringio.rb	2011-02-19 11:27:24 UTC (rev 5235)
@@ -471,4 +471,13 @@
       expected_pos += 1
     end
   end
+
+  def test_frozen
+    s = StringIO.new
+    s.freeze
+    bug = '[ruby-core:33648]'
+    assert_raise(RuntimeError, bug) {s.puts("foo")}
+    assert_raise(RuntimeError, bug) {s.string = "foo"}
+    assert_raise(RuntimeError, bug) {s.reopen("")}
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110219/5b406d00/attachment-0001.html>


More information about the macruby-changes mailing list