summaryrefslogtreecommitdiff
path: root/test/fiddle/test_function.rb
diff options
context:
space:
mode:
authorKenta Murata <mrkn@users.noreply.github.com>2020-12-11 09:41:12 +0900
committerGitHub <noreply@github.com>2020-12-11 09:41:12 +0900
commit9b0c36b39032cffff3c62a2b0e1fc38fa429f5ea (patch)
tree667648b7563a97e5d5270baccd5654d5de91358c /test/fiddle/test_function.rb
parent6b1d2de6cc2e85fda7885fe77dbd7c99c4eb1ef2 (diff)
Import fiddle-1.0.4 (#3860)
I don't use tool/sync_default_gem.rb because the last sync was incomplete. Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: sinisterchipmunk <sinisterchipmunk@gmail.com> Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Notes
Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
Diffstat (limited to 'test/fiddle/test_function.rb')
-rw-r--r--test/fiddle/test_function.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/fiddle/test_function.rb b/test/fiddle/test_function.rb
index 0bb66f9b8d..742615a56b 100644
--- a/test/fiddle/test_function.rb
+++ b/test/fiddle/test_function.rb
@@ -21,6 +21,17 @@ module Fiddle
assert_equal 'sin', func.name
end
+ def test_need_gvl?
+ libruby = Fiddle.dlopen(nil)
+ rb_str_dup = Function.new(libruby['rb_str_dup'],
+ [:voidp],
+ :voidp,
+ need_gvl: true)
+ assert(rb_str_dup.need_gvl?)
+ assert_equal('Hello',
+ Fiddle.dlunwrap(rb_str_dup.call(Fiddle.dlwrap('Hello'))))
+ end
+
def test_argument_errors
assert_raise(TypeError) do
Function.new(@libm['sin'], TYPE_DOUBLE, TYPE_DOUBLE)
@@ -111,8 +122,7 @@ module Fiddle
n1 = f.call(nil, 0, msec)
n2 = th.value
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
- delta = EnvUtil.apply_timeout_scale(180)
- assert_in_delta(msec, t1 - t0, delta, 'slept amount of time')
+ assert_in_delta(msec, t1 - t0, 180, 'slept amount of time')
assert_equal(0, n1, perror("poll(2) in main-thread"))
assert_equal(0, n2, perror("poll(2) in sub-thread"))
end