Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-Term-Shell/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Term-Shell/t/02default.t
package main;
use strict;
use warnings;

use Test::More tests => 6;

package MyShell;
use base qw(Term::Shell);

sub run_command1  { print "command1\n"; }
sub smry_command1 { "what does command1 do?" }

sub help_command1
{
    <<'END';
Help on 'command1', whatever that may be...
END
}

sub run_command2 { print "command2\n"; }

package main;

my $shell = MyShell->new;

#=============================================================================
# Command completions
#=============================================================================
my $cmds = [ $shell->possible_actions( 'e', 'run' ) ];

# TEST
is_deeply( $cmds, ['exit'], "e command" );

$cmds = [ $shell->possible_actions( 'h', 'run' ) ];

# TEST
is_deeply( $cmds, ['help'], "help command" );

$cmds = [ $shell->possible_actions( 'c', 'run' ) ];

# TEST
is( scalar(@$cmds), 2, "c run" );

#=============================================================================
# Help completions
#=============================================================================
$cmds = [ $shell->possible_actions( 'e', 'help' ) ];

# TEST
is_deeply( $cmds, ['exit'], "e completions" );

$cmds = [ $shell->possible_actions( 'h', 'help' ) ];

# TEST
is_deeply( $cmds, ['help'], 'h completions' );

$cmds = [ $shell->possible_actions( 'c', 'help' ) ];

# TEST
is_deeply( $cmds, ['command1'], 'command1 completions' );

Hry