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 From 58e2c65913b60fd1c36c9779455cb745a895db21 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:27:39 +1300 Subject: Add lyrics save() method test Not terribly comprehensive, but way better than nothing. --- MANIFEST | 1 + t/save.t | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 t/save.t diff --git a/MANIFEST b/MANIFEST index a1c175c..1a2fbd9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -7,6 +7,7 @@ README t/basic.t t/japh.lrc t/load.t +t/save.t xt/manifest.t xt/pod-coverage.t xt/pod.t diff --git a/t/save.t b/t/save.t new file mode 100644 index 0000000..27c5020 --- /dev/null +++ b/t/save.t @@ -0,0 +1,26 @@ +#!perl -T + +use strict; +use warnings; +use utf8; + +use 5.006; + +use English qw(-no_match_vars); +use File::Temp qw(tempfile); +use Test::More tests => 2; + +use Music::Lyrics::LRC; + +our $VERSION = '0.10'; + +my $lrc = Music::Lyrics::LRC->new(); +$lrc->set_tag( 'foo', 'bar' ); +$lrc->add_lyric( 0, 'lalala' ); +$lrc->add_lyric( 10, 'doremi' ); + +my ( $fh, $fn ) = tempfile(); +ok( $lrc->save($fh), 'save' ); +close $fh + or die "$ERRNO\n"; +ok( -s $fn == 44, 'length' ); ## no critic (ProhibitMagicNumbers) -- cgit v1.2.3 From 27c3cbdf8102e0cd0af661fe37d809563d2d69a0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:36:55 +1300 Subject: Add new test module reqs to build requirements --- Makefile.PL | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.PL b/Makefile.PL index cac8e48..b2ddd08 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -15,6 +15,8 @@ WriteMakefile( 'ExtUtils::MakeMaker' => '0', }, BUILD_REQUIRES => { + 'English' => '0', + 'File::Temp' => '0', 'Test::More' => '0', }, PREREQ_PM => { -- cgit v1.2.3 From 89043420bec344e95c7052f296ad346a0742f401 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:38:56 +1300 Subject: Remove doc warning about barren test suite It's a fair bit better now. --- lib/Music/Lyrics/LRC.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Music/Lyrics/LRC.pm b/lib/Music/Lyrics/LRC.pm index 4f8d3fb..d9b914c 100644 --- a/lib/Music/Lyrics/LRC.pm +++ b/lib/Music/Lyrics/LRC.pm @@ -454,8 +454,6 @@ Fractional seconds of any length can be parsed, and preserved in the millisecond count return by C, but any resolution beyond 2 decimal places is lost on C. -The test suite is skeletal, and needs a lot of fleshing out. - =head1 AUTHOR Tom Ryder C<< >> -- cgit v1.2.3 From 33a38fd85f8944f4b99c91d1f3538856363db99c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:42:39 +1300 Subject: Bump version number to 0.11 --- Makefile.PL | 2 +- lib/Music/Lyrics/LRC.pm | 4 ++-- t/basic.t | 2 +- t/load.t | 2 +- t/save.t | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index b2ddd08..2f35c7c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -27,7 +27,7 @@ WriteMakefile( 'meta-spec' => { version => 2 }, provides => { 'Music::Lyrics::LRC' => { - version => '0.10', + version => '0.11', file => 'lib/Music/Lyrics/LRC.pm', }, }, diff --git a/lib/Music/Lyrics/LRC.pm b/lib/Music/Lyrics/LRC.pm index d9b914c..842702d 100644 --- a/lib/Music/Lyrics/LRC.pm +++ b/lib/Music/Lyrics/LRC.pm @@ -13,7 +13,7 @@ use Carp; use English '-no_match_vars'; # Declare package version -our $VERSION = '0.10'; +our $VERSION = '0.11'; # Patterns to match elements of the LRC file; these are somewhat tolerant our %RE = ( @@ -272,7 +272,7 @@ Music::Lyrics::LRC - Manipulate LRC karaoke timed lyrics files =head1 VERSION -Version 0.10 +Version 0.11 =head1 DESCRIPTION diff --git a/t/basic.t b/t/basic.t index d849044..6092db0 100644 --- a/t/basic.t +++ b/t/basic.t @@ -8,7 +8,7 @@ use Test::More tests => 9; use Music::Lyrics::LRC; -our $VERSION = '0.10'; +our $VERSION = '0.11'; my $lrc = Music::Lyrics::LRC->new(); ok( defined $lrc, 'constructed' ); diff --git a/t/load.t b/t/load.t index 026117b..17242f2 100644 --- a/t/load.t +++ b/t/load.t @@ -11,7 +11,7 @@ use Test::More tests => 11; use Music::Lyrics::LRC; -our $VERSION = '0.10'; +our $VERSION = '0.11'; my $lrc = Music::Lyrics::LRC->new(); diff --git a/t/save.t b/t/save.t index 27c5020..ad55df8 100644 --- a/t/save.t +++ b/t/save.t @@ -12,7 +12,7 @@ use Test::More tests => 2; use Music::Lyrics::LRC; -our $VERSION = '0.10'; +our $VERSION = '0.11'; my $lrc = Music::Lyrics::LRC->new(); $lrc->set_tag( 'foo', 'bar' ); -- cgit v1.2.3 From 19c9596faef3f7f2ce0ac5affb849ed41f6997ec Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:43:23 +1300 Subject: Update README.markdown from perldoc --- README.markdown | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 742f74e..c4d45ce 100644 --- a/README.markdown +++ b/README.markdown @@ -4,7 +4,7 @@ Music::Lyrics::LRC - Manipulate LRC karaoke timed lyrics files # VERSION -Version 0.10 +Version 0.11 # DESCRIPTION @@ -170,8 +170,6 @@ Fractional seconds of any length can be parsed, and preserved in the millisecond count return by `lyrics()`, but any resolution beyond 2 decimal places is lost on `save()`. -The test suite is skeletal, and needs a lot of fleshing out. - # AUTHOR Tom Ryder `` -- cgit v1.2.3 From c880aa00e6aaa9d41282e14304793e7fa9e4bbfc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 8 Dec 2017 13:44:02 +1300 Subject: Update Changes for v0.11 --- Changes | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changes b/Changes index 416ac2f..75581c3 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Music-Lyrics-LRC +0.11 2017-12-08 + + - Add basic load() and save() method tests + 0.10 2017-12-06 - Add dependency links to documentation -- cgit v1.2.3