more unit tests

Closes Homebrew/homebrew#42096.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2015-07-20 21:46:05 +02:00
parent a675aae553
commit ca1f5dc713
5 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,27 @@
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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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