From 2ad7fb6dc16baee28c3840bce6d43cc6698aaa6c Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 6 May 2018 09:53:33 +0000 Subject: optparse: Suppress warnings Ruby warns "instance variable `@version` not initialized" for optparse when it receives `--version` option. `test.rb` ```ruby require 'optparse' Version = '1' OptionParser.new.parse(ARGV) ``` ``` $ ruby -w test.rb --version /home/pocke/.rbenv/versions/2.5.1/lib/ruby/2.5.0/optparse.rb:1168: warning: instance variable @version not initialized /home/pocke/.rbenv/versions/2.5.1/lib/ruby/2.5.0/optparse.rb:1175: warning: instance variable @release not initialized test 1 ``` This change will suppress the warnings. [Fix GH-1871] From: Masataka Pocke Kuwabara git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/optparse/test_summary.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/optparse') diff --git a/test/optparse/test_summary.rb b/test/optparse/test_summary.rb index 2f389a3535..67b05672d4 100644 --- a/test/optparse/test_summary.rb +++ b/test/optparse/test_summary.rb @@ -48,6 +48,8 @@ class TestOptionParser::SummaryTest < TestOptionParser def test_ver o = OptionParser.new("foo bar") o.program_name = "foo" + assert_warning('') {assert_nil(o.version)} + assert_warning('') {assert_nil(o.release)} o.version = [0, 1] assert_equal "foo 0.1", o.ver o.release = "rel" -- cgit v1.2.3