File: test-warnings.patch

package info (click to toggle)
libdata-sorting-perl 0.9-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 196 kB
  • sloc: perl: 863; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Subject: Fix warnings when comparing arrays
Date: Wed, 22 Jul 2009 13:29:28 +0200
From: Ansgar Burchardt <ansgar@43-1.org>
X-Forwarded: https://rt.cpan.org/Ticket/Display.html?id=48088

This patch fixes several warnings like

    Argument "Foo12a" isn't numeric in numeric ne (!=)
    at t/sort_tests.pl line 18.

that showed up in t/misc and t/substrs.

We use Perl 5.10's ~~ operator to compare arrays for equality now.

Take 2:

Author: gregor herrmann <gregoa@debian.org>
Description: we now use Array::Compare, since the ~~ operator has changed in
 5.10.1. From perldelta:

    It is now a run-time error to use the smart match operator "~~" with an
    object that has no overload defined for it. (This way "~~" will not break
    encapsulation by matching against the object's internal representation as a
    reference.)

Bugs-Debian: #546236

--- a/t/sort_tests.pl
+++ b/t/sort_tests.pl
@@ -1,5 +1,7 @@
 # t/sort_tests.pl -- utility routines for Data::Sorting test scripts.
 
+use Array::Compare;
+
 # Inspiried by test.pl from Sort::Naturally by Sean M. Burke
 
 sub shuffle {
@@ -13,13 +15,8 @@
   # warn "Checking: " . join( ', ', map "'$_'", @$array ) . "\n";
   CANDIDATE: foreach my $candidate (@_) {
     # warn "Against: " . join( ', ', map "'$_'", @$candidate ) . "\n";
-    next CANDIDATE unless ( $#$array = $#$candidate );
-    foreach my $idx ( 0 .. $#$array ) {
-      next CANDIDATE unless ( $array->[$idx] eq $candidate->[$idx] 
-    or $array->[$idx] != 0 and $array->[$idx] == $candidate->[$idx] );
-    }
-    # warn "Matched!";
-    return 1;
+    my $comp = Array::Compare->new;
+    return 1 if $comp->compare( $array, $candidate );
   }
   # warn( "Didn't match!" );
   return