[rubygems/rubygems] fix: Gem::Platform.match handles String argument properly

Previously 9eead86 introduced non-commutativity of platforms, and
later commit 1b9f7f50 changed the behavior of `Gem::Platform.match` to
ensure the callee of `#=~` was the gem platform.

However, when the platform argument is a String, then the callee and
argument of `#=~` are flipped (see docs for `String#=~`), which works
against the fix from 1b9f7f50.

Closes #5938

3b1fb562e8
This commit is contained in:
Mike Dalessio 2022-09-19 15:39:32 -04:00 committed by git
parent 5d4048e0bc
commit 8f7f12ad64
2 changed files with 8 additions and 0 deletions

View file

@ -452,6 +452,13 @@ class TestGemPlatform < Gem::TestCase
assert_equal 1, result.scan(/@version=/).size
end
def test_gem_platform_match_with_string_argument
util_set_arch "x86_64-linux-musl"
assert(Gem::Platform.match(Gem::Platform.new("x86_64-linux")), "should match Gem::Platform")
assert(Gem::Platform.match("x86_64-linux"), "should match String platform")
end
def assert_local_match(name)
assert_match Gem::Platform.local, name
end