Errata

Perl Testing: A Developer's Notebook

Errata for Perl Testing: A Developer's Notebook

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 3
3rd line

On page 1, 3rd last line, you say 'if you have a C compiler', and then on page 3, 3rd line you say 'that has an appropriate compiler'. I think the text on page 3 was meant to read 'that does not have.'

Anonymous   
Printed Page 14
2nd "What About" Answer

"and add the following lines to the end of analyze_sentence.t:". Calculating the number of words in $sentence here, at the end of the script, will result in a failure because we are testing for 18 words. However, a few lines above, we changed $sentence to "Rampaging ideas flutter greedily.", which is four words.

Anonymous   
Printed Page 14
second A: on page

as written test 6 in analyze_sentence.t will fail because @word will have 4 elements, not 18. To fix the example I made an amateurish change to this: #!perl use strict; use warnings; use Test::More tests =>6 ; my @subs = qw( words count_words ); #use_ok( 'AnalyzeSentence', @subs ); #BEGIN { use_ok( 'AnalyzeSentence', @subs, '$WORD_SEPARATOR' ) or exit;} #as example for testing variable $WORD_SEPARATOR BEGIN { my @subs = qw( words count_words ); use_ok( 'AnalyzeSentence', @subs, '$WORD_SEPARATOR' ) or exit; } can_ok( __PACKAGE__, 'words' ); can_ok( __PACKAGE__, 'count_words' ); my $sentence1 = 'Queen Esther, ruler of the Frog-Human Alliance, briskly devours a monumental ice cream sundae in her honor.'; my @words = words( $sentence1 ); ok( @words == 17, 'words( ) should return all words in sentence' ); my $sentence = 'Rampaging ideas flutter greedily.'; my $count = count_words( $sentence ); ok( $count == 4, 'count_words( ) should handle simple sentences' ); $WORD_SEPARATOR = qr/(?:s|-)+/; @words = words( $sentence1 ); ok( @words == 18, '...respecting $WORD_SEPARATOR, if set' );

Anonymous   
Printed Page 15
Around the 3th line

The BEGIN statement errata is already posted, but it will still fail because the last defining of $sentence only has 4 words. In order to get the test right, the last three lines of analyze_sentence.t should be as shown below. Note that you need to type in once again the "Queen Esther" sentence because we want the word count to be 18 due to "Frog-Human" now being counted as two words. $sentence = 'Queen Esther, ruler of the Frog-Human Alliance, briskly devours a monumental ice cream sundae in her honor.'; $WORD_SEPARATOR = qr/(?:s|-)+/; @words = words( $sentence ); ok( @words == 18, '... respecting $WORD_SEPARATOR, if set' );

Anonymous   
Printed Page 51
example - between.t

There is still an error using test_out() instead of test_pass(): > perl between.t 1..3 not ok 1 - simple alphabetical comparison # Failed test 'simple alphabetical comparison' # in between.t at line 14. # STDOUT is: # ok 1 - simple alphabetical comparison # # not: # simple alphabetical comparison # # as expected not ok 2 - simple numeric comparison # Failed test 'simple numeric comparison' # in between.t at line 19. # STDOUT is: # ok 1 - simple numeric comparison # # not: # simple numeric comparison # # as expected ok 3 - failed comparison with diagnostics

Anonymous   
Printed Page 51
example - between.t

Further to my previous report regarding test_out(), the solution is to change the first two instances of test_out() to: test_out("ok 1 - $desc");

Anonymous   
Printed Page 54
1st code example new_harness.pl

The following line in new_harness.pl reads... my %results = $strap->analyze_file( $file ); It should be... my $results = $strap->analyze_file( $file ); ---------------------------------------------------------------- The following line in new_harness.pl reads... printf <<END_REPORT, $file, @results{qw( max seen ok skip todo bonus )}; It should be... printf <<END_REPORT, $file, @$results{qw( max seen ok skip todo bonus )};

Anonymous   
Printed Page 54
2nd paragraph

Page 53 says that the new harness script needs to be stored as 'new_harness.pl' somewhere in the $PATH. On page 54 this script is executed as 'new_harness t/strap*t'. Either the script needs to be stored as 'new_harness' inside $PATH or it needs to be executed as 'new_harness.pl t/strap*t.

Anonymous   
Printed Page 129
Program my $g = Scorekeeper::Game->create({});

my $g = Scorekeeper::Game->create({}); throws a syntax error. Can't insert new Scorekeeper::Game: DBD::SQLite::db prepare_cached failed: near ")": syntax error [for Statement "INSERT INTO game () VALUES () It seems that at least in my versions a date is necessary, i.e. my $g = Scorekeeper::Game->create({date=>20140525}); same for a few line later my $g2 = Scorekeeper::Game->create({data=>20130525});

Volker Persch  May 25, 2014 
Printed Page 157
output from `prove -v queue.t'

The output from `prove' on this page is the same as the output from pages 153-154. That is, it's the output of `prove' when run against the original Queue::Test module described on page 152, which doesn't have any fixtures. The updated Queue::Test module described on pages 156-157 uses a fixture to create two Queue objects before running each of the other test methods. The output from `prove' when run against this updated module should be something like the text below, which matches the description in the second paragraph on page 157 (under the heading "What just happened?"): "...There are a total of six isa checks..." t/queue....1..12 ok 1 - The object isa Queue ok 2 - The object isa Queue ok 3 - empty queue ok 4 - first item ok 5 - second item ok 6 - The object isa Queue ok 7 - The object isa Queue ok 8 - queue is now larger ok 9 - The object isa Queue ok 10 - The object isa Queue ok 11 - an empty queue ok 12 - a queue with some elements ok All tests successful. Files=1, Tests=12, 0 wallclock secs ( 0.08 cusr + 0.00 csys = 0.08 CPU)

Anonymous