O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Verification by Pattern

Just for linguistic diversity and because regular expressions are easier, let’s translate our example to Perl. To show that some of our techniques apply outside of an object-oriented context, let’s also make this procedural Perl (see Listing 7-4).

Listing 7-4: Listing 7-1 rewritten in Perl

package pattern;sub describeAddition {  my $left = shift;  my $right = shift;  my $sum = $left + $right;  return "The sum of $left and $right is $sum";}

Listing 7-5 shows how our original exact equality test might look like using Test::Unit, the Perl entry into the xUnit family.

Listing 7-5: Listing 7-2 rewritten in Perl using Test::Unit

use Test::Unit::Procedural;use pattern; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required