Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version: add empty? method #7846

Merged
merged 1 commit into from Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions Library/Homebrew/test/version_spec.rb
Expand Up @@ -173,6 +173,16 @@
expect(versions.sort_by { |v| described_class.create(v) }).to eq(versions)
end

describe "#empty?" do
it "returns true if version is empty" do
expect(described_class.create("").empty?).to eq(true)
end

it "returns false if version is not empty" do
expect(described_class.create("1.2.3").empty?).to eq(false)
end
end

specify "hash equality" do
v1 = described_class.create("0.1.0")
v2 = described_class.create("0.1.0")
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/version.rb
Expand Up @@ -429,6 +429,10 @@ def <=>(other)
end
alias eql? ==

def empty?
version.empty?
end

def hash
version.hash
end
Expand Down