Bug 10644: (follow-up) remove inadvertant dependence on Perl 5.14
authorGalen Charlton <gmc@esilibrary.com>
Fri, 9 Aug 2013 18:53:20 +0000 (18:53 +0000)
committerChris Hall <followingthepath@gmail.com>
Tue, 17 Sep 2013 07:57:20 +0000 (19:57 +1200)
Perl 5.14 changed array and hash container functions (e.g., keys())
to accept hashrefs or arrayrefs.  However, this doesn't work in
Perl 5.10, so doing

  scalar(keys( function_returning_hashref() ) );

is a syntax error in that version.  This patch changes the affected
tests to explicitly difference the hashrefs returned by the various
functions.

To test:

Verify that t/db_dependent/ClassSource.t passes.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 8f933bc040e8e4198f5278253191a7a4233467ce)
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
(cherry picked from commit 9504e00f7b497aa8e49567ca99cf73f7c32ad134)
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
(cherry picked from commit 9504e00f7b497aa8e49567ca99cf73f7c32ad134)
Signed-off-by: Chris Hall <followingthepath@gmail.com>
(cherry picked from commit 4e474580b16024d6a6afc36bf220ebab034cb26a)

t/db_dependent/ClassSource.t

index 5656ec7..5e8a0ec 100644 (file)
@@ -34,12 +34,12 @@ $dbh->do(q|DELETE FROM class_sources|);
 $dbh->do(q|DELETE FROM class_sort_rules|);
 
 #Test AddClassSortRule
-my $countSources  = scalar( keys(GetClassSources) );
-my $countSources2 = scalar( keys(GetClassSortRules) );
+my $countSources  = scalar( keys(%{ GetClassSources() }) );
+my $countSources2 = scalar( keys(%{ GetClassSortRules() }) );
 AddClassSortRule( 'sortrule1', 'description1', 'routine1' );
 AddClassSortRule( 'sortrule2', 'description2', 'routine2' );
 is(
-    scalar( keys(GetClassSortRules) ),
+    scalar( keys(%{ GetClassSortRules() }) ),
     $countSources + 2,
     "SortRule1 and SortRules2 have been added"
 );
@@ -48,7 +48,7 @@ is(
 AddClassSource( 'source1', 'Description_source1', 1, 'sortrule1' );
 AddClassSource( 'source2', 'Description_source2', 0, 'sortrule1' );
 is(
-    scalar( keys(GetClassSources) ),
+    scalar( keys(%{ GetClassSources() }) ),
     $countSources2 + 2,
     "Source1 and source2 have been added"
 );
@@ -148,24 +148,24 @@ is_deeply( \@sources, [],
 
 #Test DelClassSortRule
 #DelClassSortRule ('sortrule1');
-#is(scalar (keys (GetClassSortRules)),1,"SortRule1 has been deleted");#FIXME : impossible if some sources exist
+#is(scalar (keys (%{ GetClassSortRules() })),1,"SortRule1 has been deleted");#FIXME : impossible if some sources exist
 DelClassSortRule('sortrule2');
-is( scalar( keys(GetClassSortRules) ), 1, "SortRule2 has been deleted" );
+is( scalar( keys(%{ GetClassSortRules() }) ), 1, "SortRule2 has been deleted" );
 DelClassSortRule();
-is( scalar( keys(GetClassSortRules) ),
+is( scalar( keys(%{ GetClassSortRules() }) ),
     1, "Without params DelClassSortRule doesn't do anything" );
 DelClassSortRule('doesnt_exist');
-is( scalar( keys(GetClassSortRules) ),
+is( scalar( keys(%{ GetClassSortRules() }) ),
     1, "With wrong id, DelClassSortRule doesn't do anything" );
 
 #Test DelClassSource
 DelClassSource('source2');
-is( scalar( keys(GetClassSources) ), 1, "Source2 has been deleted" );
+is( scalar( keys(%{ GetClassSources() }) ), 1, "Source2 has been deleted" );
 DelClassSource();
-is( scalar( keys(GetClassSources) ),
+is( scalar( keys(%{ GetClassSources() }) ),
     1, "Without params DelClassSource doesn't do anything" );
 DelClassSource('doesnt_exist');
-is( scalar( keys(GetClassSources) ),
+is( scalar( keys(%{ GetClassSources() }) ),
     1, "With wrong id, DelClassSource doesn't do anything" );
 
 #Test ModClassSortRule