#!./perl
my $file;
BEGIN {
$file = $0;
chdir 't' if -d 't';
}
}
END {
# let VMS whack all versions
}
# these names are hardcoded in Term::Cap
grep { -f $_ }
}
else {
}
my $writable = 1;
} else {
$writable = 0;
}
# termcap_path -- the names are hardcoded in Term::Cap
SKIP: {
# this is ugly, but -f $0 really *ought* to work
'termcap_path() should find file from $ENV{TERMCAP}' );
'termcap_path() should find file from $ENV{TERMPATH}' );
}
# make a Term::Cap "object"
my $t = {
PADDING => 1,
};
# see if Tpad() works
$t->{PADDING} = 2;
'Trequire() should croak with unsupported cap' );
my $warn;
$warn = $_[0];
};
# test the first few features by forcing Tgetent() to croak (line 156)
my $vals = {};
# check values for very slow speeds
SKIP: {
# now see if lines 177 or 180 will fail
}
SKIP: {
# it won't find the termtype in this fake file, so it should croak
$vals->{TERM} = 'quux';
$ENV{TERMPATH} = 'tcout';
eval { $t = Term::Cap->Tgetent($vals) };
# it shouldn't try to read one file more than 32(!) times
# see __END__ for a really awful termcap example
$ENV{TERMPATH} = join(' ', ('tcout') x 33);
$vals->{TERM} = 'bar';
eval { $t = Term::Cap->Tgetent($vals) };
# now let it read a fake termcap file, and see if it sets properties
$ENV{TERMPATH} = 'tcout';
$vals->{TERM} = 'baz';
$t = Term::Cap->Tgetent($vals);
is( $t->{_f1}, 1, 'Tgetent() should set a single field correctly' );
is( $t->{_f2}, 1, 'Tgetent() should set another field on the same line' );
is( $t->{_no}, '', 'Tgetent() should set a blank field correctly' );
is( $t->{_k1}, 'v1', 'Tgetent() should set a key value pair correctly' );
# and it should have set these two fields
is( $t->{_pc}, "\0", 'should set _pc field correctly' );
is( $t->{_bc}, "\b", 'should set _bc field correctly' );
}
# Tgoto has comments on the expected formats
$t->{_test} = "a%d";
is( $t->Tgoto('test', '', 1, *OUT), 'a1', 'Tgoto() should handle %d code' );
is( $out->read(), 'a1', 'Tgoto() should print to filehandle if passed' );
$t->{_test} = "a%.";
like( $t->Tgoto('test', '', 1), qr/^a\x01/, 'Tgoto() should handle %.' );
if (ord('A') == 193) { # EBCDIC platform
like( $t->Tgoto('test', '', 0), qr/\x81\x01\x16/,
'Tgoto() should handle %. and magic' );
} else { # ASCII platform
like( $t->Tgoto('test', '', 0), qr/\x61\x01\x08/,
'Tgoto() should handle %. and magic' );
}
$t->{_test} = 'a%+';
like( $t->Tgoto('test', '', 1), qr/a\x01/, 'Tgoto() should handle %+' );
$t->{_test} = 'a%+a';
is( $t->Tgoto('test', '', 1), 'ab', 'Tgoto() should handle %+char' );
$t->{_test} .= 'a' x 99;
'Tgoto() should substr()s %+ if needed' );
$t->{_test} = '%ra%d';
is( $t->Tgoto('test', 1, ''), 'a1', 'Tgoto() should swaps params with %r' );
$t->{_test} = 'a%>11bc';
is( $t->Tgoto('test', '', 1), 'abc', 'Tgoto() should unpack args with %>' );
$t->{_test} = 'a%21';
is( $t->Tgoto('test'), 'a001', 'Tgoto() should format with %2' );
$t->{_test} = 'a%31';
is( $t->Tgoto('test'), 'a0001', 'Tgoto() should also formats with %3' );
$t->{_test} = '%ia%21';
is( $t->Tgoto('test', '', 1), 'a021', 'Tgoto() should increment args with %i' );
$t->{_test} = '%z';
is( $t->Tgoto('test'), 'OOPS', 'Tgoto() should catch invalid args' );
# and this is pretty standard
package TieOut;
sub TIEHANDLE {
bless( \(my $self), $_[0] );
}
sub PRINT {
my $self = shift;
$$self .= join('', @_);
}
sub read {
my $self = shift;
}
__END__
bar: :tc=bar: \
baz: \
:f1: :f2: \
:no@ \
:k1#v1\
:k2=v2\\n2