summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-07-23 15:11:24 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-07-31 21:07:19 +0900
commit561576367beeb1237a3821db1b0ab9ef66e9fb56 (patch)
tree40e069b75137580ac75bfe721bf72b485e04499d
parent1a935606b5e307375ce9d4215a46da2ca91dc1d6 (diff)
[rubygems/rubygems] Deduplicate the requirement operators in memory
https://github.com/rubygems/rubygems/commit/9963d33cf2
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3379
-rw-r--r--lib/rubygems/requirement.rb2
-rw-r--r--test/rubygems/test_gem_requirement.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index 65bc837..d9d7c2f 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -111,7 +111,7 @@ class Gem::Requirement
elsif $1 == ">=" && $2 == "0.a"
DefaultPrereleaseRequirement
else
- [$1 || "=", Gem::Version.new($2)]
+ [-($1 || "="), Gem::Version.new($2)]
end
end
diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
index 55a902d..af9d807 100644
--- a/test/rubygems/test_gem_requirement.rb
+++ b/test/rubygems/test_gem_requirement.rb
@@ -81,6 +81,12 @@ class TestGemRequirement < Gem::TestCase
Gem::Requirement.parse(Gem::Version.new('2'))
end
+ if RUBY_VERSION >= '2.5'
+ def test_parse_deduplication
+ assert_same '~>', Gem::Requirement.parse('~> 1').first
+ end
+ end
+
def test_parse_bad
[
nil,