diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-03 15:22:16 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-03 15:22:16 +0900 |
commit | 89cef1c56b3a0f9c5e6ccc22a5044477a4fd16c1 (patch) | |
tree | 3daaf29ea56b9703b9eea59d899f58cb1d7d8cb0 /spec/ruby/core/objectspace/define_finalizer_spec.rb | |
parent | dcedf0a008f07f38e570c70b3872fa37e837be4a (diff) | |
download | ruby-89cef1c56b3a0f9c5e6ccc22a5044477a4fd16c1.tar.gz |
Version guard for [Feature #15974]
Diffstat (limited to 'spec/ruby/core/objectspace/define_finalizer_spec.rb')
-rw-r--r-- | spec/ruby/core/objectspace/define_finalizer_spec.rb | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/spec/ruby/core/objectspace/define_finalizer_spec.rb b/spec/ruby/core/objectspace/define_finalizer_spec.rb index 3a9132ef93..fef7667039 100644 --- a/spec/ruby/core/objectspace/define_finalizer_spec.rb +++ b/spec/ruby/core/objectspace/define_finalizer_spec.rb @@ -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_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 - - ruby_exe(code, :options => "-w", :args => "2>&1").should include("warning: object is reachable from finalizer - it may never be run") + 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 + + 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") + end end end |