| 1 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | package Test::Deep::PDL; | ||||||||||
| 5 | |||||||||||
| 6 | =head1 NAME | ||||||||||
| 7 | |||||||||||
| 8 | Test::Deep::PDL - Test ndarrays inside data structures with Test::Deep | ||||||||||
| 9 | |||||||||||
| 10 | =for Pod::Coverage init descend diag_message renderExp renderGot | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | 1 | our $VERSION = '0.22'; | |||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | use Test::Deep::Cmp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | require Test::PDL; | |||||||||
| 18 | |||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||
| 20 | |||||||||||
| 21 | This is just an implementation class. Look at the documentation for test_pdl() | ||||||||||
| 22 | in L<Test::PDL>. | ||||||||||
| 23 | |||||||||||
| 24 | =cut | ||||||||||
| 25 | |||||||||||
| 26 | sub init | ||||||||||
| 27 | 109 | ▶ | { | ||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 28 | 109 | my $self = shift; | |||||||||
| 29 | 109 | my $expected = shift; | |||||||||
| 30 | 109 | ▶ | die "Supplied value is not an ndarray" unless eval { $expected->isa('PDL') }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 109 | $self->{expected} = $expected; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | sub descend | ||||||||||
| 35 | 93 | ▶ | { | ||||||||
|
Subroutine
descend: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 36 | 93 | my $self = shift; | |||||||||
| 37 | 93 | my $got = shift; | |||||||||
| 38 | 93 | ( my $ok, $self->data->{diag} ) = Test::PDL::eq_pdl( $got, $self->{expected} ); | |||||||||
| 39 | 93 | return $ok; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub diag_message | ||||||||||
| 43 | 3 | ▶ | { | ||||||||
|
Subroutine
diag_message: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 44 | 3 | my $self = shift; | |||||||||
| 45 | 3 | my $where = shift; | |||||||||
| 46 | 3 | return "Comparing $where as an ndarray:\n" . $self->data->{diag}; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | sub renderExp | ||||||||||
| 50 | 3 | ▶ | { | ||||||||
|
Subroutine
renderExp: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 51 | 3 | my $self = shift; | |||||||||
| 52 | 3 | return $self->renderGot( $self->{expected} ); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub renderGot | ||||||||||
| 56 | 6 | ▶ | { | ||||||||
|
Subroutine
renderGot: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 57 | 6 | my $self = shift; | |||||||||
| 58 | 6 | my $val = shift; | |||||||||
| 59 | 6 | my $fmt = '%-8T %-12D (%-5S) '; | |||||||||
| 60 | 6 | ▶ | return eval { $val->isa('PDL') } ? ($val->info($fmt) . $val) : ("(" . Test::Deep::render_val($val) . ")"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | =head1 BUGS | ||||||||||
| 64 | |||||||||||
| 65 | The implementation of this class depends on undocumented subroutines in | ||||||||||
| 66 | L<Test::Deep>. This may break if L<Test::Deep> gets refactored. | ||||||||||
| 67 | |||||||||||
| 68 | =head1 SEE ALSO | ||||||||||
| 69 | |||||||||||
| 70 | L<PDL>, L<Test::PDL>, L<Test::Deep> | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | 1 | 1; | |||||||||