4 if( $ENV{PERL_CORE} ) {
6 @INC = ('../lib', 'lib');
14 use Test::More tests => 11;
15 use ExtUtils::MakeMaker;
22 like( $@, qr/^Not enough arguments for ExtUtils::MakeMaker::prompt/,
28 like( $@, qr/^prompt function called without an argument/,
31 my $stdout = tie *STDOUT, 'TieOut' or die;
34 $ENV{PERL_MM_USE_DEFAULT} = 1;
35 is( prompt("Foo?"), '', 'no default' );
36 like( $stdout->read, qr/^Foo\?\s*\n$/, ' question' );
38 is( prompt("Foo?", undef), '', 'undef default' );
39 like( $stdout->read, qr/^Foo\?\s*\n$/, ' question' );
41 is( prompt("Foo?", 'Bar!'), 'Bar!', 'default' );
42 like( $stdout->read, qr/^Foo\? \[Bar!\]\s+Bar!\n$/, ' question' );
46 skip "eof() doesn't honor ties in 5.5.3", 3 if $] < 5.006;
48 $ENV{PERL_MM_USE_DEFAULT} = 0;
50 my $stdin = tie *STDIN, 'TieIn' or die;
51 $stdin->write("From STDIN");
52 ok( !-t STDIN, 'STDIN not a tty' );
54 is( prompt("Foo?", 'Bar!'), 'From STDIN', 'from STDIN' );
55 like( $stdout->read, qr/^Foo\? \[Bar!\]\s*$/, ' question' );