1 2 3 4 5 6 7 8 9
sub function { ... if ( ... ) { warn "Warning message!"; print "Press ENTER"; my $dummy = <STDIN>; } ... }
1 2 3 4 5 6 7 8
use Test::More; use Test::FailWarnings; use Capture::Tiny qw( capture_merged ); ok( my $dummy = capture_stdout{ my $d = choose( function( { opt1 => val1 } ) } ); ok( my $dummy = capture_stdout{ my $d = choose( function( { opt2 => val2 } ) } ); done_testing;
1 2 3 4 5 6 7 8 9 10
use Test::More; use Test::Fatal; use Capture::Tiny qw( capture_merged ); $SIG{__WARN__} = sub { die @_ }; is( exception { my $dummy = capture_merged{ function( { opt1 => val1 } ) } }, undef, "{ opt1 => val1 } does not warn" ); is( exception { my $dummy = capture_merged{ function( { opt2 => val2 } ) } }, undef, "{ opt2 => val2 } does not warn" ); done_testing;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/perl use warnings; use strict; use Term::ReadKey; ReadMode 4; warn "Warning message!"; print "Press ENTER"; while (1) { my $key = ReadKey(-1); unless(defined $key) {$key = "";} if ($key eq "\n") { last; } } ReadMode 0;
1 2 3 4
close STDIN; my $stdin = "eingabe\n"; open STDIN, "<", \$stdin or die $!; # tests...