7.11. More than one test

We can then setup lot's of tests and run them through one invocation of bc.

Example 7-5. examples/bc/bc5.pl

#!/usr/bin/perl
use strict;
use warnings;

use Expect;
use Test::More qw(no_plan);
$Expect::Log_Stdout = 0;

my @sets = (
    [23+7,     30],
    ['23+7',   30],
    ['11+1',   10],
    ['2*21',   42],
);
 
my $e = Expect->new;
$e->spawn("bc") or die "Could not start bc\n";
$e->expect(undef, "warranty") or die "no warranty\n";

foreach my $set (@sets) {
    $e->send("$$set[0]\n");
    ok($e->expect(1, $$set[1]), $$set[0]);
}
$e->send("quit\n");