diff --git a/modules/t/circularSlice.t b/modules/t/circularSlice.t index a026e20734969a7bfdec083ceb5879a7919fe234..71ef32907aabed56a2b997cefa1d7a0668093c8f 100644 --- a/modules/t/circularSlice.t +++ b/modules/t/circularSlice.t @@ -337,21 +337,28 @@ foreach my $sl (sort keys %{$slices}) { foreach my $table (@tables) { my $query; + + my $table_in_stable_id_tables = 0; + foreach my $stable_id_table (@stable_id_tables) { + $table_in_stable_id_tables = 1 if $stable_id_table eq $table; + last; + } + if ($sstart > $send) { - $query = sprintf $query_templates[0], $table, $table ~~ @stable_id_tables?', stable_id':'', $table, $seq_id, $sstart, $send, $sstart, $send; - } else { - $query = sprintf $query_templates[1], $table, $table ~~ @stable_id_tables?', stable_id':'', $table, $seq_id, $send, $sstart, $send, $sstart; + $query = sprintf $query_templates[0], $table, $table_in_stable_id_tables ? ', stable_id':'', $table, $seq_id, $sstart, $send, $sstart, $send; + } + else { + $query = sprintf $query_templates[1], $table, $table_in_stable_id_tables ? ', stable_id':'', $table, $seq_id, $send, $sstart, $send, $sstart; } - my $expected_objects = - $sql_helper->execute( - -SQL => $query, - -USE_HASHREFS => 1, - -CALLBACK => sub { - my $row = shift @_; - - return feature_slice_boundaries($row, $sstart, $send, $sstrand, $srl); - }); + my $expected_objects = $sql_helper->execute( + -SQL => $query, + -USE_HASHREFS => 1, + -CALLBACK => sub { + my $row = shift @_; + return feature_slice_boundaries($row, $sstart, $send, $sstrand, $srl); + } + ); my $method = ucfirst($table); $method =~ s/_([a-z])/\u$1/g; $method = sprintf 'get_all_%ss', $method; # print "Calling $method\n"; @@ -359,25 +366,19 @@ foreach my $sl (sort keys %{$slices}) { is(scalar @{$got_objects}, scalar @{$expected_objects}, sprintf "Number of $table objects on slice [%d, %d]", $sstart, $send); foreach my $expected (@{$expected_objects}) { - my $got = (grep { $expected->{db_id} == $_->dbID } @{$got_objects})[0]; - - SKIP: { - skip 'Cannot test attributes with no returned object', 1 unless $got; - - ok($got, sprintf "Object of type $table (%d) retrieved", $got->dbID); - is($got->stable_id, $expected->{stable_id}, sprintf "%d: stable id", $got->dbID) - if $table ~~ @stable_id_tables; - is($got->start, $expected->{start}, sprintf "%d: start", $got->dbID); - is($got->end, $expected->{end}, sprintf "%d: end", $got->dbID); - is($got->strand, $expected->{strand}, sprintf "%d: strand", $got->dbID); - } - - } + my $got = (grep { $expected->{db_id} == $_->dbID } @{$got_objects})[0]; + SKIP: { + skip 'Cannot test attributes with no returned object', 1 unless $got; + ok($got, sprintf "Object of type $table (%d) retrieved", $got->dbID); + is($got->stable_id, $expected->{stable_id}, sprintf "%d: stable id", $got->dbID) if $table_in_stable_id_tables; + is($got->start, $expected->{start}, sprintf "%d: start", $got->dbID); + is($got->end, $expected->{end}, sprintf "%d: end", $got->dbID); + is($got->strand, $expected->{strand}, sprintf "%d: strand", $got->dbID); + } + } } - } - } # diff --git a/modules/t/schemaPatches.t b/modules/t/schemaPatches.t index 8b62b8e63e6e4d5b46e1a5e16cc16e342fbe2d94..70f7896c4006ba7d33b099996cf8f43d226fa842 100644 --- a/modules/t/schemaPatches.t +++ b/modules/t/schemaPatches.t @@ -180,8 +180,6 @@ sub compare_after_patches { $dbc->do("use $source_schema"); my $source_patches = $sql_helper->execute_simple(-SQL => "select meta_value from meta where meta_key='patch' and meta_value like 'patch_${last_release}_${current_release}_%'"); - # Does not work on <5.10 versions of Perl - # map { ok($_ ~~ @{$source_patches}, "$_ in patched database") } @{$target_patches}; my %source_patches; map { $source_patches{$_}++ } @{$source_patches}; map { ok(exists $source_patches{$_}, "$_ in patched database") } @{$target_patches};