Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 97 lines (86 sloc) 4.041 kb
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
Reading database from ...


------------------------------------------ ------ ------ ------ ------ ------
File stmt bran cond sub total
------------------------------------------ ------ ------ ------ ------ ------
tests/sort 94.7 n/a n/a 80.0 91.7
Total 94.7 n/a n/a 80.0 91.7
------------------------------------------ ------ ------ ------ ------ ------


Run: ...
Perl version: ...
OS: ...
Start: ...
Finish: ...

tests/sort

line err stmt bran cond sub code
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 1 my %sort =
6 (
7 B => \&backwards,
8 F => \&forwards
9 );
10
11 sub backwards
12 {
13 9 9 return $b cmp $a;
14 }
15
16 sub forwards
17 {
18 *** 0 0 return $a cmp $b;
19 }
20
21 sub GetAlgorithm
22 {
23 1 1 my ($alg) = @_;
24 1 return $sort{$alg};
25 }
26
27 1 my @list = qw( a d e c g );
28
29 # my $alg = GetAlgorithm(('B', 'F')[int(rand(2))]);
30 1 my $alg = GetAlgorithm(('B', 'F')[0]);
31
32 1 @list = sort {&{$alg}} @list;
               9
               9
33
34 use Data::Dumper;
35
36 1 print STDERR Dumper(\@list);
37
38 package Failure;
39
40 sub fail
41 {
42 1 1 my @x = 1 .. 5;
43 1 my @y = sort { Failure->xyz( $a, $b ) } @x;
               4
44 }
45
46 sub xyz
47 {
48 4 4 my $self = shift;
49 4 my ($a, $b) = @_;
50 4 $a <=> $b;
51 }
52 package main;
53
54 1 my @l = Failure->fail;
55
56 1 print STDERR Dumper(\@l);


Covered Subroutines
-------------------

Subroutine Count Location
------------ ----- -------------
GetAlgorithm 1 tests/sort:23
backwards 9 tests/sort:13
fail 1 tests/sort:42
xyz 4 tests/sort:48

Uncovered Subroutines
---------------------

Subroutine Count Location
------------ ----- -------------
forwards 0 tests/sort:18
Something went wrong with that request. Please try again.