Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (45 sloc) 1.183 kB
use strict;
use warnings;
use CGI::Header;
use Test::More tests => 19;
my %alias = (
'TIEHASH' => 'new',
'FETCH' => 'get',
'STORE' => 'set',
'DELETE' => 'delete',
'EXISTS' => 'exists',
'CLEAR' => 'clear',
);
can_ok 'CGI::Header', ( keys %alias, 'SCALAR' );
my $class = 'CGI::Header';
while ( my ($got, $expected) = each %alias ) {
is $class->can($got), $class->can($expected);
}
my $header = tie my %header, 'CGI::Header';
isa_ok tied %header, 'CGI::Header';
# SCALAR
%{ $header->header } = ();
ok %header;
%{ $header->header } = ( -type => q{} );
ok !%header;
# CLEAR
%{ $header->header } = ();
%header = ();
is_deeply $header->header, { -type => q{} };
# EXISTS
%{ $header->header } = ( -foo => 'bar', -bar => q{} );
ok exists $header{Foo};
ok exists $header{Bar};
ok !exists $header{Baz};
# DELETE
%{ $header->header } = ( -foo => 'bar', -bar => 'baz' );
is delete $header{Foo}, 'bar';
is_deeply $header->header, { -bar => 'baz' };
# FETCH
%{ $header->header } = ( -foo => 'bar' );
is $header{Foo}, 'bar';
is $header{Bar}, undef;
# STORE
%{ $header->header } = ();
$header{Foo} = 'bar';
is_deeply $header->header, { -foo => 'bar' };
Jump to Line
Something went wrong with that request. Please try again.