mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Version guard for [Feature #15974]
This commit is contained in:
parent
dcedf0a008
commit
89cef1c56b
1 changed files with 23 additions and 21 deletions
|
@ -66,29 +66,31 @@ describe "ObjectSpace.define_finalizer" do
|
|||
ruby_exe(code).lines.sort.should == ["finalized1\n", "finalized2\n"]
|
||||
end
|
||||
|
||||
it "warns in verbose mode if it is self-referencing" do
|
||||
code = <<-RUBY
|
||||
obj = "Test"
|
||||
handler = Proc.new { puts "finalized" }
|
||||
ObjectSpace.define_finalizer(obj, handler)
|
||||
exit 0
|
||||
RUBY
|
||||
ruby_version_is "2.7" do
|
||||
it "warns in verbose mode if it is self-referencing" do
|
||||
code = <<-RUBY
|
||||
obj = "Test"
|
||||
handler = Proc.new { puts "finalized" }
|
||||
ObjectSpace.define_finalizer(obj, handler)
|
||||
exit 0
|
||||
RUBY
|
||||
|
||||
ruby_exe(code, :options => "-w", :args => "2>&1").should include("warning: object is reachable from finalizer - it may never be run")
|
||||
end
|
||||
ruby_exe(code, :options => "-w", :args => "2>&1").should include("warning: object is reachable from finalizer - it may never be run")
|
||||
end
|
||||
|
||||
it "warns in verbose mode if it is indirectly self-referencing" do
|
||||
code = <<-RUBY
|
||||
def scoped(indirect)
|
||||
Proc.new { puts "finalized" }
|
||||
end
|
||||
obj = "Test"
|
||||
indirect = [obj]
|
||||
handler = scoped(indirect)
|
||||
ObjectSpace.define_finalizer(obj, handler)
|
||||
exit 0
|
||||
RUBY
|
||||
it "warns in verbose mode if it is indirectly self-referencing" do
|
||||
code = <<-RUBY
|
||||
def scoped(indirect)
|
||||
Proc.new { puts "finalized" }
|
||||
end
|
||||
obj = "Test"
|
||||
indirect = [obj]
|
||||
handler = scoped(indirect)
|
||||
ObjectSpace.define_finalizer(obj, handler)
|
||||
exit 0
|
||||
RUBY
|
||||
|
||||
ruby_exe(code, :options => "-w", :args => "2>&1").should include("warning: object is reachable from finalizer - it may never be run")
|
||||
ruby_exe(code, :options => "-w", :args => "2>&1").should include("warning: object is reachable from finalizer - it may never be run")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue