more core unit tests
Closes Homebrew/homebrew#47182. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
parent
f258949816
commit
a6d2723ef5
@ -13,4 +13,8 @@ class JsonSmokeTest < Homebrew::TestCase
|
|||||||
json = '{"foo":["bar","baz"],"qux":1}'
|
json = '{"foo":["bar","baz"],"qux":1}'
|
||||||
assert_equal hash, Utils::JSON.load(json)
|
assert_equal hash, Utils::JSON.load(json)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_decode_failure
|
||||||
|
assert_raises(Utils::JSON::Error) { Utils::JSON.load("nope") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -35,6 +35,7 @@ class PatchTests < Homebrew::TestCase
|
|||||||
|
|
||||||
def test_raises_for_unknown_values
|
def test_raises_for_unknown_values
|
||||||
assert_raises(ArgumentError) { Patch.create(Object.new) }
|
assert_raises(ArgumentError) { Patch.create(Object.new) }
|
||||||
|
assert_raises(ArgumentError) { Patch.create(Object.new, Object.new) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -100,3 +101,25 @@ class LegacyPatchTests < Homebrew::TestCase
|
|||||||
assert_empty Patch.normalize_legacy_patches(nil)
|
assert_empty Patch.normalize_legacy_patches(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class EmbeddedPatchTests < Homebrew::TestCase
|
||||||
|
def test_inspect
|
||||||
|
p = EmbeddedPatch.new :p1
|
||||||
|
assert_equal "#<EmbeddedPatch: :p1>", p.inspect
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class ExternalPatchTests < Homebrew::TestCase
|
||||||
|
def setup
|
||||||
|
@p = ExternalPatch.new(:p1) { url "file:///my.patch" }
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_url
|
||||||
|
assert_equal "file:///my.patch", @p.url
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_inspect
|
||||||
|
assert_equal %(#<ExternalPatch: :p1 "file:///my.patch">), @p.inspect
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -37,4 +37,14 @@ class PkgVersionTests < Homebrew::TestCase
|
|||||||
assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s
|
assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s
|
||||||
assert_equal "HEAD", PkgVersion.new(Version.new("HEAD"), 1).to_s
|
assert_equal "HEAD", PkgVersion.new(Version.new("HEAD"), 1).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_hash
|
||||||
|
p1 = PkgVersion.new(Version.new("1.0"), 1)
|
||||||
|
p2 = PkgVersion.new(Version.new("1.0"), 1)
|
||||||
|
p3 = PkgVersion.new(Version.new("1.1"), 1)
|
||||||
|
p4 = PkgVersion.new(Version.new("1.0"), 0)
|
||||||
|
assert_equal p1.hash, p2.hash
|
||||||
|
refute_equal p1.hash, p3.hash
|
||||||
|
refute_equal p1.hash, p4.hash
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -31,4 +31,10 @@ I'm not indented
|
|||||||
|
|
||||||
assert_equal "hello\ngoodbye\n\n", undented
|
assert_equal "hello\ngoodbye\n\n", undented
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_inreplace_sub_failure
|
||||||
|
s = "foobar".extend StringInreplaceExtension
|
||||||
|
s.sub! "not here", "test"
|
||||||
|
assert_equal [%(expected replacement of "not here" with "test")], s.errors
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user