Reduce output - turn it into a test script
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
examples/bc/bc4.pl
#!/usr/bin/perl use strict; use warnings; use Expect; use Test::More tests => 5; my $e = Expect->new; $e->log_stdout(0); #$e->raw_pty(1); $e->spawn("bc") or die "Cannot run bc\n"; my $warranty; $e->expect(1, ["warranty'\." => sub { $warranty = 1; }]); ok $warranty, 'warranty'; $e->send("23+7\n"); 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'); $e->send("quit\n");
- $e->log_stdout(0); - turn off the printing to the screen