8 use Test::More tests => 11;
9 use ExtUtils::MakeMaker;
16 like( $@, qr/^Not enough arguments for ExtUtils::MakeMaker::prompt/,
22 like( $@, qr/^prompt function called without an argument/,
25 my $stdout = tie *STDOUT, 'TieOut' or die;
28 $ENV{PERL_MM_USE_DEFAULT} = 1;
29 is( prompt("Foo?"), '', 'no default' );
30 like( $stdout->read, qr/^Foo\?\s*\n$/, ' question' );
32 is( prompt("Foo?", undef), '', 'undef default' );
33 like( $stdout->read, qr/^Foo\?\s*\n$/, ' question' );
35 is( prompt("Foo?", 'Bar!'), 'Bar!', 'default' );
36 like( $stdout->read, qr/^Foo\? \[Bar!\]\s+Bar!\n$/, ' question' );
40 skip "eof() doesn't honor ties in 5.5.3", 3 if $] < 5.006;
42 $ENV{PERL_MM_USE_DEFAULT} = 0;
44 my $stdin = tie *STDIN, 'TieIn' or die;
45 $stdin->write("From STDIN");
46 ok( !-t STDIN, 'STDIN not a tty' );
48 is( prompt("Foo?", 'Bar!'), 'From STDIN', 'from STDIN' );
49 like( $stdout->read, qr/^Foo\? \[Bar!\]\s*$/, ' question' );