File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,11 @@ def setup
1818 def teardown
1919 # Ensure freeing all closures.
2020 # 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 )
2326 end
2427
2528 def test_default_abi
@@ -82,18 +85,20 @@ def test_call
8285 end
8386
8487 def test_argument_count
85- closure = Class . new ( Closure ) {
88+ closure_class = Class . new ( Closure ) do
8689 def call one
8790 10 + one
8891 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 )
9492 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
97102 end
98103 end
99104
You can’t perform that action at this time.
0 commit comments