summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/optparse.rb4
-rw-r--r--test/optparse/test_summary.rb2
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 11b122de953..2a2098e2564 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -1165,14 +1165,14 @@ XXX
# Version
#
def version
- @version || (defined?(::Version) && ::Version)
+ (defined?(@version) && @version) || (defined?(::Version) && ::Version)
end
#
# Release code
#
def release
- @release || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE)
+ (defined?(@release) && @release) || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE)
end
#
diff --git a/test/optparse/test_summary.rb b/test/optparse/test_summary.rb
index 2f389a35357..67b05672d4e 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"