[前][次][番号順一覧][スレッド一覧]

ruby-changes:22942

From: naruse <ko1@a...>
Date: Tue, 13 Mar 2012 00:17:40 +0900 (JST)
Subject: [ruby-changes:22942] naruse:r34991 (trunk): Add missing assert_warning.

naruse	2012-03-13 00:17:27 +0900 (Tue, 13 Mar 2012)

  New Revision: 34991

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34991

  Log:
    Add missing assert_warning.

  Modified files:
    trunk/test/ruby/test_io_m17n.rb
    trunk/test/ruby/test_m17n_comb.rb

Index: test/ruby/test_io_m17n.rb
===================================================================
--- test/ruby/test_io_m17n.rb	(revision 34990)
+++ test/ruby/test_io_m17n.rb	(revision 34991)
@@ -1,6 +1,7 @@
 require 'test/unit'
 require 'tmpdir'
 require 'timeout'
+require 'stringio'
 require_relative 'envutil'
 
 class TestIO_M17N < Test::Unit::TestCase
@@ -11,6 +12,17 @@
     Encoding::UTF_8
   ]
 
+  def assert_warning(pat, mesg=nil)
+    begin
+      org_stderr = $stderr
+      $stderr = StringIO.new(warn = '')
+      yield
+    ensure
+      $stderr = org_stderr
+    end
+    assert_match(pat, warn, mesg)
+  end
+
   def with_tmpdir
     Dir.mktmpdir {|dir|
       Dir.chdir(dir) {
@@ -1064,9 +1076,9 @@
     bug5567 = '[ruby-core:40726]'
     IO.pipe do |r, w|
       assert_nothing_raised(bug5567) do
-        assert_warn(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx")}
-        assert_warn(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx", "us-ascii")}
-        assert_warn(/Unsupported/, bug5567) {r.set_encoding("us-ascii", "fffffffffffxx")}
+        assert_warning(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx")}
+        assert_warning(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx", "us-ascii")}
+        assert_warning(/Unsupported/, bug5567) {r.set_encoding("us-ascii", "fffffffffffxx")}
       end
     end
   end
Index: test/ruby/test_m17n_comb.rb
===================================================================
--- test/ruby/test_m17n_comb.rb	(revision 34990)
+++ test/ruby/test_m17n_comb.rb	(revision 34991)
@@ -1,5 +1,4 @@
 require 'test/unit'
-require 'stringio'
 require_relative 'allpairs'
 
 class TestM17NComb < Test::Unit::TestCase
@@ -23,62 +22,6 @@
     assert_equal(a(bytes), a(actual), message)
   end
 
-  def assert_warning(pat, mesg=nil)
-    begin
-      org_stderr = $stderr
-      $stderr = StringIO.new(warn = '')
-      yield
-    ensure
-      $stderr = org_stderr
-    end
-    assert_match(pat, warn, mesg)
-  end
-
-  def assert_regexp_generic_encoding(r)
-    assert(!r.fixed_encoding?)
-    %w[ASCII-8BIT EUC-JP Shift_JIS UTF-8].each {|ename|
-      # "\xc2\xa1" is a valid sequence for ASCII-8BIT, EUC-JP, Shift_JIS and UTF-8.
-      assert_nothing_raised { r =~ "\xc2\xa1".force_encoding(ename) }
-    }
-  end
-
-  def assert_regexp_fixed_encoding(r)
-    assert(r.fixed_encoding?)
-    %w[ASCII-8BIT EUC-JP Shift_JIS UTF-8].each {|ename|
-      enc = Encoding.find(ename)
-      if enc == r.encoding
-        assert_nothing_raised { r =~ "\xc2\xa1".force_encoding(enc) }
-      else
-        assert_raise(ArgumentError) { r =~ "\xc2\xa1".force_encoding(enc) }
-      end
-    }
-  end
-
-  def assert_regexp_generic_ascii(r)
-    assert_encoding("ASCII-8BIT", r.encoding)
-    assert_regexp_generic_encoding(r)
-  end
-
-  def assert_regexp_fixed_ascii8bit(r)
-    assert_encoding("ASCII-8BIT", r.encoding)
-    assert_regexp_fixed_encoding(r)
-  end
-
-  def assert_regexp_fixed_eucjp(r)
-    assert_encoding("EUC-JP", r.encoding)
-    assert_regexp_fixed_encoding(r)
-  end
-
-  def assert_regexp_fixed_sjis(r)
-    assert_encoding("Shift_JIS", r.encoding)
-    assert_regexp_fixed_encoding(r)
-  end
-
-  def assert_regexp_fixed_utf8(r)
-    assert_encoding("UTF-8", r.encoding)
-    assert_regexp_fixed_encoding(r)
-  end
-
   STRINGS = [
     a(""), e(""), s(""), u(""),
     a("a"), e("a"), s("a"), u("a"),

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]