\x20\40\x20\40 HEX
HEX
Server: Apache
System: Linux web1.jenscom.net 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64
User: sps (1059)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/.cpan/build/ExtUtils-MakeMaker-7.70-0/t/prompt.t
#!/usr/bin/perl -w

BEGIN {
    unshift @INC, 't/lib';
}

use strict;
use warnings;
use Test::More tests => 11;
use ExtUtils::MakeMaker;
use TieOut;
use TieIn;

eval q{
    prompt();
};
like( $@, qr/^Not enough arguments for ExtUtils::MakeMaker::prompt/,
                                            'no args' );

eval {
    prompt(undef);
};
like( $@, qr/^prompt function called without an argument/,
                                            'undef message' );

my $stdout = tie *STDOUT, 'TieOut' or die;


$ENV{PERL_MM_USE_DEFAULT} = 1;
is( prompt("Foo?"), '',     'no default' );
like( $stdout->read,  qr/^Foo\?\s*\n$/,      '  question' );

is( prompt("Foo?", undef), '',     'undef default' );
like( $stdout->read,  qr/^Foo\?\s*\n$/,      '  question' );

is( prompt("Foo?", 'Bar!'), 'Bar!',     'default' );
like( $stdout->read,  qr/^Foo\? \[Bar!\]\s+Bar!\n$/,      '  question' );

$ENV{PERL_MM_USE_DEFAULT} = 0;
close STDIN;
my $stdin = tie *STDIN, 'TieIn' or die;
$stdin->write("From STDIN");
ok( !-t STDIN,      'STDIN not a tty' );

is( prompt("Foo?", 'Bar!'), 'From STDIN',     'from STDIN' );
like( $stdout->read,  qr/^Foo\? \[Bar!\]\s*$/,      '  question' );