about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-23 20:43:09 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-23 20:43:09 -0800
commitc57db265632314a663268aceb1213ce6a7d8c83f (patch)
treed4a0f847ed5d44c4672a54a4fa19b955910c8969
parentc3d0e079729eedbccd6f8ddee0bdac9ae9fdcc6b (diff)
downloadruby_posix_mq-c57db265632314a663268aceb1213ce6a7d8c83f.tar.gz
DL in Ruby 1.9 isn't the same
-rw-r--r--test/test_posix_mq.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 3dcaa90..4a661e8 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -102,8 +102,17 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     libcs.each do |libc|
       if File.readable?(libc)
         require "dl"
+        begin
+          require "fiddle"
+        rescue LoadError
+        end
         libc = DL.dlopen libc
-        alarm = libc["alarm", "II"]
+        if defined?(Fiddle)
+          alarm = libc["alarm"]
+          alarm = Fiddle::Function.new(alarm, [DL::TYPE_INT], DL::TYPE_INT)
+        else
+          alarm = libc["alarm", "II"]
+        end
         break
       end
     end
@@ -111,7 +120,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     alarms = 0
     trap("ALRM") { alarms += 1 }
     interval = 1
-    alarm[interval]
+    alarm.call interval
     @mq = POSIX_MQ.new(@path, :rw)
     assert ! @mq.nonblock?
     t0 = Time.now