From f99523388f35c2d0e32694bdaa0d4f695976ef21 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 24 Jul 2019 22:21:49 +0900 Subject: Suppress uninitialized instance variable warnings In verbose mode, `test_delegator` in `test/psych/visitors/test_yaml_tree.rb` shows following warning. https://travis-ci.org/ruby/psych/jobs/562435717#L268 ``` /home/travis/build/ruby/psych/test/psych/visitors/test_yaml_tree.rb:10: warning: instance variable @obj not initialized ``` This is because `Psych.load` bypasses #initialize with the #init_with method. --- test/psych/visitors/test_yaml_tree.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb index 01f1aec..69885ee 100644 --- a/test/psych/visitors/test_yaml_tree.rb +++ b/test/psych/visitors/test_yaml_tree.rb @@ -7,7 +7,7 @@ module Psych class TestDelegatorClass < Delegator def initialize(obj); super; @obj = obj; end def __setobj__(obj); @obj = obj; end - def __getobj__; @obj; end + def __getobj__; @obj if defined?(@obj); end end class TestSimpleDelegatorClass < SimpleDelegator -- cgit v1.2.3