Thread Term::Choose (13 answers)
Opened by Kuerbis at 2012-07-27 18:58

Kuerbis
 2014-07-31 21:05
#176660 #176660
User since
2011-03-20
947 Artikel
BenutzerIn
[default_avatar]
Hallo, kann mir jemand einen Tipp geben, warum dieser Test "failed"?
CPAN Testers Reports

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use 5.010001;
use warnings;
use strict;
use Test::More;

eval "use Expect";
if ( $@ ) {
    plan skip_all => "Expect required for choose_1.t test.";
}

my $exp = Expect->new();
$exp->raw_pty( 1 );
$exp->log_stdout( 0 );

my $command     = 'perl';
my $script      = 't/choose_1.pl';
my @parameters  = ( $script );

ok( -r $script, "$script is readable" );

ok( -x $script, "$script is executable" );

ok( $exp->spawn( $command, @parameters ), "Spawn '$command @parameters' OK" );

$exp->send( "\x{0d}" );

my $expected = 'choice: 1';

my $ret = $exp->expect( 2, $expected );

ok( $ret, 'matched something' );

ok( $exp->match() eq $expected, "expected: '$expected', got: '" . $exp->match() . "'" );

done_testing();



choose_1.pl:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env perl
use warnings;
use strict;
use 5.010001;

use Term::Choose qw( choose );

my $choice = choose(
    [ 1 ]
);

say "choice: $choice";


Wenn ich es bei mir teste, funktioniert es.

View full thread Term::Choose