From dff26eae9fc8d0a26b7d8f768f88e810f59478ce Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:14:56 +1300 Subject: Add file load testing --- MANIFEST | 2 ++ t/japh.lrc | 10 ++++++++++ t/load.t | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 t/japh.lrc create mode 100644 t/load.t diff --git a/MANIFEST b/MANIFEST index a250116..a1c175c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5,6 +5,8 @@ Makefile.PL MANIFEST README t/basic.t +t/japh.lrc +t/load.t xt/manifest.t xt/pod-coverage.t xt/pod.t diff --git a/t/japh.lrc b/t/japh.lrc new file mode 100644 index 0000000..83ad9e4 --- /dev/null +++ b/t/japh.lrc @@ -0,0 +1,10 @@ +[ar:J A Phacker] +[ti:Just Another Perl Hacker] + +[01:53.53] I'm just another Perl hacker, +this line should get skipped + +[01:59]And you know the world's my oyster, +[01:56.560]Matchin' up the world. + +[02:02.4]And my language is its pearl. diff --git a/t/load.t b/t/load.t new file mode 100644 index 0000000..42d10a5 --- /dev/null +++ b/t/load.t @@ -0,0 +1,37 @@ +#!perl -T + +use strict; +use warnings; +use utf8; + +use 5.006; + +use English qw(-no_match_vars); +use Test::More tests => 11; + +use Music::Lyrics::LRC; + +our $VERSION = '0.10'; + +my $lrc = Music::Lyrics::LRC->new(); + +open my $fh, '<', 't/japh.lrc' or die "$ERRNO\n"; +ok( $lrc->load($fh), 'loaded' ); +close $fh or die "$ERRNO\n"; + +my %tags = %{ $lrc->tags }; +ok( %tags == 2, 'tags_count' ); + +my @lyrics = @{ $lrc->lyrics }; +ok( @lyrics == 4, 'lines_count' ); + +ok( $lyrics[0]{text} eq q{I'm just another Perl hacker,}, 'line_text_1' ); +ok( $lyrics[1]{text} eq q{Matchin' up the world.}, 'line_text_2' ); +ok( $lyrics[2]{text} eq q{And you know the world's my oyster,}, 'line_text_3' ); +ok( $lyrics[3]{text} eq q{And my language is its pearl.}, 'line_text_4' ); + +## no critic (ProhibitMagicNumbers) +ok( $lyrics[0]{time} == 113_530, 'line_time_1' ); +ok( $lyrics[1]{time} == 116_560, 'line_time_2' ); +ok( $lyrics[2]{time} == 119_000, 'line_time_3' ); +ok( $lyrics[3]{time} == 122_400, 'line_time_4' ); -- cgit v1.2.3 From 0528f7f6a94e31bfa7a43dc51427d314061f55de Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:16:22 +1300 Subject: Count %tags more correctly in load test --- t/load.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/load.t b/t/load.t index 42d10a5..026117b 100644 --- a/t/load.t +++ b/t/load.t @@ -20,7 +20,7 @@ ok( $lrc->load($fh), 'loaded' ); close $fh or die "$ERRNO\n"; my %tags = %{ $lrc->tags }; -ok( %tags == 2, 'tags_count' ); +ok( keys %tags == 2, 'tags_count' ); my @lyrics = @{ $lrc->lyrics }; ok( @lyrics == 4, 'lines_count' ); -- cgit v1.2.3