diff options
author | Sutou Kouhei <kou@clear-code.com> | 2020-12-25 06:02:19 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-05-18 12:48:40 +0900 |
commit | 881b2dc89865c1b7a7fbc2c89e13789a068f335d (patch) | |
tree | f260f58a809a6b7df12c978f02847894a5eb5f26 /test/fiddle | |
parent | b2de5999d88d81310b3c9f0c1f14451d7eca8e6e (diff) |
[ruby/fiddle] closure: add support for const char *
GitHub: fix GH-62
Reported by Cody Krieger. Thanks!!!
https://github.com/ruby/fiddle/commit/284b820f2d
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4506
Diffstat (limited to 'test/fiddle')
-rw-r--r-- | test/fiddle/test_closure.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/fiddle/test_closure.rb b/test/fiddle/test_closure.rb index 6ccd3859f5..9e748bf5ee 100644 --- a/test/fiddle/test_closure.rb +++ b/test/fiddle/test_closure.rb @@ -54,6 +54,19 @@ module Fiddle assert_equal 10, func.call(10) end + def test_const_string + closure_class = Class.new(Closure) do + def call(string) + @return_string = "Hello! #{string}" + @return_string + end + end + closure = closure_class.new(:const_string, [:const_string]) + + func = Function.new(closure, [:const_string], :const_string) + assert_equal("Hello! World!", func.call("World!")) + end + def test_block_caller cb = Closure::BlockCaller.new(TYPE_INT, [TYPE_INT]) do |one| one |