Compare Tag using standardized_arch.

This commit is contained in:
Markus Reiter 2023-05-05 06:05:58 +02:00
parent b0dc84b117
commit 4c3e8255cf
No known key found for this signature in database
GPG Key ID: 245293B51702655B
2 changed files with 23 additions and 5 deletions

View File

@ -36,6 +36,15 @@ describe Utils::Bottles::Tag do
expect(tag.to_sym).to eq(symbol)
end
describe "#==" do
it "compares using the standardized arch" do
monterey_intel = described_class.new(system: :monterey, arch: :intel)
monterex_x86_64 = described_class.new(system: :monterey, arch: :x86_64)
expect(monterey_intel).to eq monterex_x86_64
end
end
describe "#standardized_arch" do
it "returns :x86_64 for :intel" do
expect(described_class.new(system: :all, arch: :intel).standardized_arch).to eq(:x86_64)
@ -47,21 +56,30 @@ describe Utils::Bottles::Tag do
end
describe "#valid_combination?" do
it "returns true for intel archs" do
it "returns true for Intel" do
tag = described_class.new(system: :big_sur, arch: :intel)
expect(tag.valid_combination?).to be true
tag = described_class.new(system: :linux, arch: :x86_64)
expect(tag.valid_combination?).to be true
end
it "returns false for arm archs and macos versions older than big_sur" do
it "returns false for ARM on macOS Catalina or older" do
tag = described_class.new(system: :catalina, arch: :arm64)
expect(tag.valid_combination?).to be false
tag = described_class.new(system: :mojave, arch: :arm)
expect(tag.valid_combination?).to be false
end
it "returns false for arm archs and linux" do
it "returns true for ARM on macOS Big Sur or newer" do
tag = described_class.new(system: :big_sur, arch: :arm64)
expect(tag.valid_combination?).to be true
tag = described_class.new(system: :monterey, arch: :arm)
expect(tag.valid_combination?).to be true
tag = described_class.new(system: :ventura, arch: :arm)
expect(tag.valid_combination?).to be true
end
it "returns false for ARM on Linux" do
tag = described_class.new(system: :linux, arch: :arm64)
expect(tag.valid_combination?).to be false
tag = described_class.new(system: :linux, arch: :arm)

View File

@ -153,7 +153,7 @@ module Utils
if other.is_a?(Symbol)
to_sym == other
else
self.class == other.class && system == other.system && arch == other.arch
self.class == other.class && system == other.system && standardized_arch == other.standardized_arch
end
end
@ -162,7 +162,7 @@ module Utils
end
def hash
[system, arch].hash
[system, standardized_arch].hash
end
sig { returns(Symbol) }