"Fossies" - the Fresh Open Source Software Archive

Member "texinfo-6.5/tp/maintain/lib/libintl-perl/tests/01trivial.t" (22 Apr 2014, 1245 Bytes) of package /linux/misc/texinfo-6.5.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # -*- perl -*-
    2 # A trivial conversion.
    3 
    4 # Before `make install' is performed this script should be runnable with
    5 # `make test'. After `make install' it should work as `perl test.pl'
    6 
    7 use strict;
    8 use Test;
    9 
   10 BEGIN { plan tests => 4 }
   11 
   12 require Locale::Recode;
   13 
   14 sub compare_internal;
   15 
   16 my $text = 'Perl';
   17 my $expect = [ unpack 'C*', $text ];
   18 my $cd = Locale::Recode->new (from => 'ISO-8859-1',
   19 							 to => 'INTERNAL');
   20 
   21 ok !$cd->getError;
   22 
   23 my $result = $text;
   24 ok $cd->recode ($result) && compare_internal $expect => $result;
   25 
   26 # Aliases!
   27 $cd = Locale::Recode->new (from => 'lAtIn2',
   28 						  to => 'l3');
   29 
   30 ok !$cd->getError;
   31 
   32 $result = $expect = $text;
   33 ok $cd->recode ($result) && $result eq $expect;
   34 
   35 sub compare_internal
   36 {
   37 	my ($bonny, $clyde) = @_;
   38 
   39 	return unless defined $bonny;
   40 	return unless defined $clyde;
   41 	return unless 'ARRAY' eq ref $bonny;
   42 	return unless 'ARRAY' eq ref $clyde;
   43 
   44 	return unless @$bonny == @$clyde;
   45 	
   46 	for (my $i = 0; $i < @$bonny; ++$i) {
   47 		return unless $bonny->[$i] == $clyde->[$i];
   48 	}
   49 
   50 	return 1;
   51 }
   52 
   53 __END__
   54 
   55 Local Variables:
   56 mode: perl
   57 perl-indent-level: 4
   58 perl-continued-statement-offset: 4
   59 perl-continued-brace-offset: 0
   60 perl-brace-offset: -4
   61 perl-brace-imaginary-offset: 0
   62 perl-label-offset: -4
   63 tab-width: 4
   64 End:
   65