aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/test_patch.rb
diff options
context:
space:
mode:
authorJack Nagel2014-03-13 19:51:23 -0500
committerJack Nagel2014-03-13 21:35:41 -0500
commit665b14c4a44c272b46b8559836e9fdbeee5d8a46 (patch)
treeb6a8bb6b962ba9590b53382c747172ad805da114 /Library/Homebrew/test/test_patch.rb
parentbc6e4a189491f0e3f911b879efec3e570029dd8e (diff)
downloadbrew-665b14c4a44c272b46b8559836e9fdbeee5d8a46.tar.bz2
Enable new patch implementation with compatibility layer
Diffstat (limited to 'Library/Homebrew/test/test_patch.rb')
-rw-r--r--Library/Homebrew/test/test_patch.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_patch.rb b/Library/Homebrew/test/test_patch.rb
index 1cc1ac7af..9056e8371 100644
--- a/Library/Homebrew/test/test_patch.rb
+++ b/Library/Homebrew/test/test_patch.rb
@@ -50,3 +50,66 @@ class PatchTests < Test::Unit::TestCase
assert_raises(ArgumentError) { Patch.create(Object.new) }
end
end
+
+class LegacyPatchTests < Test::Unit::TestCase
+ def test_patch_single_string
+ patches = Patch.normalize_legacy_patches("http://example.com/patch.diff")
+ assert_equal 1, patches.length
+ assert_equal :p1, patches.first.strip
+ end
+
+ def test_patch_array
+ patches = Patch.normalize_legacy_patches(
+ %w{http://example.com/patch1.diff http://example.com/patch2.diff}
+ )
+
+ assert_equal 2, patches.length
+ assert_equal :p1, patches[0].strip
+ assert_equal :p1, patches[1].strip
+ end
+
+ def test_p0_hash_to_string
+ patches = Patch.normalize_legacy_patches(
+ :p0 => "http://example.com/patch.diff"
+ )
+
+ assert_equal 1, patches.length
+ assert_equal :p0, patches.first.strip
+ end
+
+ def test_p1_hash_to_string
+ patches = Patch.normalize_legacy_patches(
+ :p1 => "http://example.com/patch.diff"
+ )
+
+ assert_equal 1, patches.length
+ assert_equal :p1, patches.first.strip
+ end
+
+ def test_mixed_hash_to_strings
+ patches = Patch.normalize_legacy_patches(
+ :p1 => "http://example.com/patch1.diff",
+ :p0 => "http://example.com/patch0.diff"
+ )
+ assert_equal 2, patches.length
+ assert_equal 1, patches.select { |p| p.strip == :p0 }.length
+ assert_equal 1, patches.select { |p| p.strip == :p1 }.length
+ end
+
+ def test_mixed_hash_to_arrays
+ patches = Patch.normalize_legacy_patches(
+ :p1 => ["http://example.com/patch10.diff",
+ "http://example.com/patch11.diff"],
+ :p0 => ["http://example.com/patch00.diff",
+ "http://example.com/patch01.diff"]
+ )
+
+ assert_equal 4, patches.length
+ assert_equal 2, patches.select { |p| p.strip == :p0 }.length
+ assert_equal 2, patches.select { |p| p.strip == :p1 }.length
+ end
+
+ def test_nil
+ assert_empty Patch.normalize_legacy_patches(nil)
+ end
+end