1use strict; 2use warnings; 3use Test::More 0.88; 4require './t/TestUtils.pm'; 5t::TestUtils->import(); 6 7# Test unbuffered paging 8 9SKIP: { 10 skip_interactive(); 11 12 require IO::Pager; 13 14 diag "\n". 15 "Reading is fun! Here is some text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\n". 16 "This text should be displayed directly on screen, not within a pager.\n". 17 "\n"; 18 19 select STDERR; 20 my $A = prompt("\nWas the text displayed directly on screen? [Yn]"); 21 ok is_yes($A), 'Diagnostic'; 22 23 { 24 local $STDOUT = new IO::Pager *BOB; # IO::Pager::Unbuffered by default 25 26 isa_ok $STDOUT, 'IO::Pager::Unbuffered'; 27 isa_ok $STDOUT, 'Tie::Handle'; 28 29 eval { 30 my $i = 0; 31 $SIG{PIPE} = sub{ "Work complete" }; 32 while (1) { 33 printf BOB "%06i Printing text in a pager. Exit at any time, usually by pressing 'Q'.\n", $i++; 34 sleep 1 unless $i%400; 35 } 36 }; 37 close BOB; 38 } 39 40 $A = prompt("\nWas the text displayed in a pager? [Yn]"); 41 ok is_yes($A), 'Unbuffered glob filehandle'; 42} 43 44done_testing; 45