Skip to content
Snippets Groups Projects
Commit ca1f5dc7 authored by Baptiste Fontaine's avatar Baptiste Fontaine
Browse files

more unit tests


Closes Homebrew/homebrew#42096.

Signed-off-by: default avatarBaptiste Fontaine <batifon@yahoo.fr>
parent a675aae5
No related branches found
No related tags found
No related merge requests found
require 'testing_env'
class CaveatsTests < Homebrew::TestCase
def setup
@f = formula { url "foo-1.0" }
@c = Caveats.new @f
end
def test_f
assert_equal @f, @c.f
end
def test_empty?
assert @c.empty?
f = formula do
url "foo-1.0"
def caveats
"something"
end
end
c = Caveats.new f
refute c.empty?
end
end
......@@ -71,6 +71,20 @@ class DependenciesTests < Homebrew::TestCase
refute_equal a, b
refute_eql a, b
end
def test_empty
a = Dependencies.new
assert a.empty?
a << Dependency.new("foo")
refute a.empty?
end
def test_inspect
a = Dependencies.new
assert_equal "#<Dependencies: []>", a.inspect
a << Dependency.new("foo")
assert_equal "#<Dependencies: [#<Dependency: \"foo\" []>]>", a.inspect
end
end
class RequirementsTests < Homebrew::TestCase
......
......@@ -257,4 +257,28 @@ class FormulaTests < Homebrew::TestCase
assert f.option_defined?("bar")
assert f.option_defined?("baz")
end
def test_desc
f = formula do
desc "a formula"
url "foo-1.0"
end
assert_equal "a formula", f.desc
end
def test_post_install_defined
f1 = formula do
url "foo-1.0"
def post_install;end
end
f2 = formula do
url "foo-1.0"
end
assert f1.post_install_defined?
refute f2.post_install_defined?
end
end
......@@ -23,6 +23,10 @@ class OptionTests < Homebrew::TestCase
assert_empty @option.description
assert_equal "foo", Option.new("foo", "foo").description
end
def test_inspect
assert_equal "#<Option: \"--foo\">", @option.inspect
end
end
class DeprecatedOptionTests < Homebrew::TestCase
......@@ -121,10 +125,21 @@ class OptionsTests < Homebrew::TestCase
assert_equal [foo, bar, baz].sort, (@options | options).sort
end
def test_times
@options << Option.new("aa") << Option.new("bb") << Option.new("cc")
assert_equal %w[--aa --bb --cc], (@options * "XX").split("XX").sort
end
def test_create_with_array
array = %w{--foo --bar}
option1 = Option.new("foo")
option2 = Option.new("bar")
assert_equal [option1, option2].sort, Options.create(array).sort
end
def test_inspect
assert_equal "#<Options: []>", @options.inspect
@options << Option.new("foo")
assert_equal "#<Options: [#<Option: \"--foo\">]>", @options.inspect
end
end
......@@ -44,4 +44,10 @@ class MacOSVersionTests < Homebrew::TestCase
assert_equal @v, MacOS::Version.from_symbol(:lion)
assert_raises(ArgumentError) { MacOS::Version.from_symbol(:foo) }
end
def test_pretty_name
assert_equal "El Capitan", MacOS::Version.new("10.11").pretty_name
assert_equal "Mountain Lion", MacOS::Version.new("10.8").pretty_name
assert_equal "Yosemite", MacOS::Version.new("10.10").pretty_name
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment