summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2011-11-22 00:01:04 +0100
committerDave Lawrence <dlawrence@mozilla.com>2011-11-22 00:01:04 +0100
commit5f1ae49c9a96fca5be3297c4d6b322df4c7ac77f (patch)
tree0dff9880cef5fdf236ebe16b788366a28599927b /t
parentb689f676ba312e3a06d1f8f68df520f5ca220381 (diff)
parent4d99c123ee568e5a548968de8417ebc70a24efe4 (diff)
downloadbugzilla-5f1ae49c9a96fca5be3297c4d6b322df4c7ac77f.tar.gz
bugzilla-5f1ae49c9a96fca5be3297c4d6b322df4c7ac77f.tar.xz
merged with bmo/4.2
Diffstat (limited to 't')
-rw-r--r--t/007util.t17
1 files changed, 15 insertions, 2 deletions
diff --git a/t/007util.t b/t/007util.t
index 742c2b2d2..b32a1b90c 100644
--- a/t/007util.t
+++ b/t/007util.t
@@ -18,7 +18,7 @@
#
# Contributor(s): Zach Lipton <zach@zachlipton.com>
# Max Kanat-Alexander <mkanat@bugzilla.org>
-
+# Frédéric Buclin <LpSolit@gmail.com>
#################
#Bugzilla Test 7#
@@ -26,7 +26,7 @@
use lib 't';
use Support::Files;
-use Test::More tests => 13;
+use Test::More tests => 15;
BEGIN {
use_ok(Bugzilla);
@@ -72,3 +72,16 @@ foreach my $input (keys %email_strings) {
is(Bugzilla::Util::email_filter($input), $email_strings{$input},
"email_filter('$input')");
}
+
+# diff_arrays():
+my @old_array = qw(alpha beta alpha gamma gamma beta alpha delta epsilon gamma);
+my @new_array = qw(alpha alpha beta gamma epsilon delta beta delta);
+# The order is not relevant when comparing both arrays for matching items,
+# i.e. (foo bar) and (bar foo) are the same arrays (same items).
+# But when returning data, we try to respect the initial order.
+# We remove the leftmost items first, and return what's left. This means:
+# Removed (in this order): gamma alpha gamma.
+# Added (in this order): delta
+my ($removed, $added) = diff_arrays(\@old_array, \@new_array);
+is_deeply($removed, [qw(gamma alpha gamma)], 'diff_array(\@old, \@new) (check removal)');
+is_deeply($added, [qw(delta)], 'diff_array(\@old, \@new) (check addition)');