about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-08-19 19:37:32 -0700
committerEric Wong <normalperson@yhbt.net>2010-08-19 19:37:32 -0700
commit748d4aa2d3ece18db7d48c355ce77c877e4d3bb9 (patch)
tree0cd9dd608789068fb99b508413e5c1f84d067f9f
parent8f5be0c822362e113919145d52b9eeebba711236 (diff)
downloadruby_posix_mq-748d4aa2d3ece18db7d48c355ce77c877e4d3bb9.tar.gz
I did not know about this method back in the day...
-rw-r--r--test/test_posix_mq.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 777b9bf..7e6ad9d 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -3,15 +3,13 @@ require 'test/unit'
 require 'posix_mq'
 require 'thread'
 require 'fcntl'
-require 'set'
 $stderr.sync = $stdout.sync = true
 
 class Test_POSIX_MQ < Test::Unit::TestCase
-  METHODS = Set.new(POSIX_MQ.instance_methods.map { |x| x.to_sym })
 
-  METHODS.include?(:to_io) or
+  POSIX_MQ.method_defined?(:to_io) or
     warn "POSIX_MQ#to_io not supported on this platform: #{RUBY_PLATFORM}"
-  METHODS.include?(:notify) or
+  POSIX_MQ.method_defined?(:notify) or
     warn "POSIX_MQ#notify not supported on this platform: #{RUBY_PLATFORM}"
 
   def setup
@@ -162,7 +160,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
     assert @mq.to_io.kind_of?(IO)
     assert_nothing_raised { IO.select([@mq], nil, nil, 0) }
-  end if METHODS.include?(:to_io)
+  end if POSIX_MQ.method_defined?(:to_io)
 
   def test_notify
     rd, wr = IO.pipe
@@ -231,7 +229,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
   def test_new_sym_w
     @mq = POSIX_MQ.new @path, :w
     assert_equal IO::WRONLY, @mq.to_io.fcntl(Fcntl::F_GETFL)
-  end if METHODS.include?(:to_io)
+  end if POSIX_MQ.method_defined?(:to_io)
 
   def test_new_sym_r
     @mq = POSIX_MQ.new @path, :w
@@ -239,7 +237,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     assert_nothing_raised { mq = POSIX_MQ.new @path, :r }
     assert_equal IO::RDONLY, mq.to_io.fcntl(Fcntl::F_GETFL)
     assert_nil mq.close
-  end if METHODS.include?(:to_io)
+  end if POSIX_MQ.method_defined?(:to_io)
 
   def test_new_path_only
     @mq = POSIX_MQ.new @path, :w
@@ -247,12 +245,12 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     assert_nothing_raised { mq = POSIX_MQ.new @path }
     assert_equal IO::RDONLY, mq.to_io.fcntl(Fcntl::F_GETFL)
     assert_nil mq.close
-  end if METHODS.include?(:to_io)
+  end if POSIX_MQ.method_defined?(:to_io)
 
   def test_new_sym_wr
     @mq = POSIX_MQ.new @path, :rw
     assert_equal IO::RDWR, @mq.to_io.fcntl(Fcntl::F_GETFL)
-  end if METHODS.include?(:to_io)
+  end if POSIX_MQ.method_defined?(:to_io)
 
   def test_new_attr
     mq_attr = POSIX_MQ::Attr.new(IO::NONBLOCK, 1, 1, 0)
@@ -287,7 +285,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     assert_nothing_raised { @mq.notify { |mq| q << "hi" } }
     assert_nothing_raised { Process.waitpid2(fork { @mq << "bye" }) }
     assert_equal "hi", q.pop
-  end if METHODS.include?(:notify)
+  end if POSIX_MQ.method_defined?(:notify)
 
   def test_notify_thread
     q = Queue.new
@@ -297,5 +295,5 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     x = q.pop
     assert x.instance_of?(Thread)
     assert Thread.current != x
-  end if METHODS.include?(:notify)
+  end if POSIX_MQ.method_defined?(:notify)
 end