We don't want to see all the output bc generates and then try to look for the correct responses or the error messages. We'd prefer just see ok or not ok

use strict;
use warnings;

use Expect;
use Test::More tests => 5;

my $e = Expect->new;
$e->spawn("bc") or die "Cannot run bc\n";

my $warranty;
$e->expect(1, ["warranty'\." => sub { $warranty = 1; }]);
ok $warranty, 'warranty';

ok($e->expect(1, -re => '\d+\+\d+'), 'echo expression');
is($e->match, '23+7', 'input');

ok($e->expect(1, -re => '\d+'), 'data received');
is($e->match, 30, 'correct response');