App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/Testing.pm view on Meta::CPAN
#! perl
use strict;
use warnings;
use utf8;
use Carp;
use FindBin;
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../lib/ChordPro/lib";
binmode STDOUT => ':utf8';
binmode STDERR => ':utf8';
package ChordPro::Testing;
use parent 'Exporter';
our @EXPORT = qw( $config );
use Test::More ();
use Test::More::UTF8;
use ChordPro::Files;
use ChordPro::Config;
use ChordPro::Paths;
use ChordPro::Chords;
sub import {
my $pkg = shift;
# This is dirty...
-d "t" && chdir "t";
$::running_under_test = 1;
Test::More->export_to_level(1);
$pkg->export_to_level( 1, undef, @EXPORT );
}
sub is_deeply {
my ( $got, $expect, $tag ) = @_;
if ( ref($got) eq 'HASH' && ref($expect) eq 'HASH' ) {
fixchords($got) if $got->{body};
for ( qw( config generate ) ) {
delete $got->{$_} unless exists $expect->{$_};
}
if ( $got->{chordsinfo} ) {
if ( !%{$got->{chordsinfo}} && !$expect->{chordsinfo} ) {
delete $got->{chordsinfo};
}
else {
foreach ( keys %{ $got->{chordsinfo} } ) {
$got->{chordsinfo}{$_} = $got->{chordsinfo}{$_}->name;
}
}
}
for ( qw( instrument user _key key_actual key_sound key_print
chords numchords
_configversion bookmark
) ) {
delete $got->{meta}->{$_} unless exists $expect->{meta}->{$_};
}
}
Test::More::is_deeply( $got, $expect, $tag );
}
push( @EXPORT, 'is_deeply' );
sub testconfig {
# May change later.
ChordPro::Config::configurator;
( run in 0.987 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )