The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

use 5.10.0;
use strict;
use FindBin qw( $RealBin );
use File::Spec::Functions qw( catfile );
BEGIN {
if ( $^O eq 'MSWin32' ) {
plan skip_all => "MSWin32: Expect not available.";
}
#if ( ! $ENV{TESTS_USING_EXPECT_OK} ) {
# plan skip_all => "Environment variable 'TESTS_USING_EXPECT_OK' not enabled.";
#}
}
eval "use Expect";
if ( $@ ) {
plan skip_all => $@;
}
my $exp;
eval {
$exp = Expect->new();
$exp->raw_pty( 1 );
$exp->log_stdout( 0 );
$exp->slave->set_winsize( 24, 80, undef, undef );
my $command = $^X;
my $script = catfile $RealBin, 'Y_choose_method_invalid_arguments.pl';
my @parameters = ( $script );
-r $script or die "$script is NOT readable";
$exp->spawn( $command, @parameters ) or die "Spawn '$command @parameters' NOT ok $!";
1;
}
or plan skip_all => $@;
my $expected = '<End_mc_ia>';
my $ret = $exp->expect( 2, [ qr/.+/ ] );
ok( $ret, 'matched something' );
my $result = $exp->match();
$result = '' if ! defined $result;
ok( $result eq $expected, "expected: '$expected', got: '$result'" );
$exp->hard_close();
done_testing();