File tree 1 file changed +15
-10
lines changed
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,11 @@ def setup
18
18
def teardown
19
19
# Ensure freeing all closures.
20
20
# See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091 .
21
- GC . start
22
- assert_equal ( 0 , ObjectSpace . each_object ( Fiddle ::Closure ) { } )
21
+ not_freed_closures = [ ]
22
+ ObjectSpace . each_object ( Fiddle ::Closure ) do |closure |
23
+ not_freed_closures << closure unless closure . freed?
24
+ end
25
+ assert_equal ( [ ] , not_freed_closures )
23
26
end
24
27
25
28
def test_default_abi
@@ -82,18 +85,20 @@ def test_call
82
85
end
83
86
84
87
def test_argument_count
85
- closure = Class . new ( Closure ) {
88
+ closure_class = Class . new ( Closure ) do
86
89
def call one
87
90
10 + one
88
91
end
89
- } . new ( TYPE_INT , [ TYPE_INT ] )
90
- func = Function . new ( closure , [ TYPE_INT ] , TYPE_INT )
91
-
92
- assert_raise ( ArgumentError ) do
93
- func . call ( 1 , 2 , 3 )
94
92
end
95
- assert_raise ( ArgumentError ) do
96
- func . call
93
+ closure_class . create ( TYPE_INT , [ TYPE_INT ] ) do |closure |
94
+ func = Function . new ( closure , [ TYPE_INT ] , TYPE_INT )
95
+
96
+ assert_raise ( ArgumentError ) do
97
+ func . call ( 1 , 2 , 3 )
98
+ end
99
+ assert_raise ( ArgumentError ) do
100
+ func . call
101
+ end
97
102
end
98
103
end
99
104
You can’t perform that action at this time.
0 commit comments