"Fossies" - the Fresh Open Source Software Archive

Member "MIME-Types-2.22/t/10type.t" (9 Dec 2020, 1075 Bytes) of package /linux/privat/MIME-Types-2.22.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env perl
    2 #
    3 # Test reporting warnings, errors and family.
    4 #
    5 
    6 use strict;
    7 use warnings;
    8 
    9 use Test::More tests => 25;
   10 use lib qw(lib t);
   11 
   12 use MIME::Type;
   13 
   14 my $a = MIME::Type->new(type => 'x-appl/x-zip', extensions => [ 'zip', 'zp' ]);
   15 ok(defined $a);
   16 
   17 is($a->type, 'x-appl/x-zip');
   18 is($a->simplified, 'appl/zip');
   19 is($a->simplified('text/plain'), 'text/plain');
   20 is(MIME::Type->simplified('x-xyz/abc'), 'xyz/abc');
   21 is($a->mainType, 'appl');
   22 is($a->subType, 'zip');
   23 ok(!$a->isRegistered);
   24 
   25 my @ext = $a->extensions;
   26 cmp_ok(scalar @ext, '==', 2);
   27 is($ext[0], 'zip');
   28 is($ext[1], 'zp');
   29 is($a->encoding, 'base64');
   30 ok($a->isBinary);
   31 ok(not $a->isAscii);
   32 
   33 my $b = MIME::Type->new(type => 'TEXT/PLAIN', encoding => '8bit');
   34 ok(defined $b);
   35 is($b->type, 'TEXT/PLAIN');
   36 is($b->simplified, 'text/plain');
   37 is($b->mainType, 'text');
   38 is($b->subType, 'plain');
   39 @ext = $b->extensions;
   40 cmp_ok(scalar @ext, '==', 0);
   41 is($b->encoding, '8bit');
   42 ok(not $b->isBinary);
   43 ok($b->isAscii);
   44 ok($b->isRegistered);
   45 
   46 my $c = MIME::Type->new(type => 'applications/x-zip');
   47 ok(!$c->isRegistered);