2
## Some functionality of Unicode-Map-0.105 is deprecated now. It is either
3
## removed from the documentation or explicitly marked deprecated there.
5
## Anyway old code applying Unicode::Map should remain intact. This test
7
## 1. The deprecated usage is still available
8
## 2. Unicode::Map issues warnings if $WARNINGS & WARN_DEPRECATION
11
# Before `make install' is performed this script should be runnable with
12
# `make test'. After `make install' it should work as `perl test.pl'
14
######################### We start with some black magic to print on failure.
16
# Change 1..1 below to 1..last_test_to_print .
17
# (It may become useful if the test is moved to ./t subdirectory.)
19
BEGIN { $| = 1; print "1..5\n"; }
20
END {print "not ok 1\n" unless $loaded;}
26
######################### End of black magic.
28
# Insert your test code below (better if it prints "ok 13"
29
# (correspondingly "not ok 13") depending on the success of chunk 13
35
my $utf16 = "\0K\0�\0s\0e";
39
map { ref($_) ? $_ : [$_] }
40
["new_no_id", "new: joker charset id"],
41
["new_id_select", "new: preselected charset id"],
42
["reverse", "reverse unicode"],
50
$len = length($test[$_]->[$#{$test[$_]}]);
51
$max = $len if $len>$max;
56
for (sort {$test[$a]->[$#{$test[$a]}] cmp $test[$b]->[$#{$test[$b]}]}
59
($name, $desc) = @{$test[$_]};
60
$desc = $name if !defined $desc;
61
_out($max, $i, $desc);
62
test ($i++, eval "&$name($_, \"$name\")");
68
my $t = sprintf " #%2d: %s ", @_;
69
$t .= "." x (9 + 4 + $max - length($t));
74
my ($number, $status) = @_;
79
print STDERR "failed!\n";
80
print "not ok $number\n";
85
## Tests if a construction like this is supported:
87
## my $Map = new Unicode::Map ( );
88
## my $utf16 = $Map -> to_unicode ( "ISO-8859-1", $str );
90
## Correct usage would be:
92
## my $Map = new Unicode::Map ( "ISO-8859-1" );
93
## my $utf16 = $Map -> to_unicode ( $str );
97
return 0 unless $warnings == 0;
98
my $Map = new Unicode::Map ( );
99
return 0 unless $warnings == 1;
100
return 0 unless $Map;
101
return 0 unless $Map -> to_unicode ( "ISO-8859-1", $locale ) eq $utf16;
102
return 0 unless $warnings == 2;
103
return 0 unless $Map -> from_unicode ( "ISO-8859-1", $utf16 ) eq $locale;
104
return 0 unless $warnings == 3;
109
## Tests if a constructor with this form is supported:
111
## new Unicode::Map ( {ID => "ISO-8859-1"} );
113
## Correct usage would be:
115
## new Unicode::Map ( "ISO-8859-1" );
119
return 0 unless $warnings == 0;
120
return 0 unless my $Map = new Unicode::Map ({ ID => "ISO-8859-1" });
121
return 0 unless $warnings == 1;
122
return 0 unless $Map -> to_unicode ( $locale ) eq $utf16;
123
return 0 unless $Map -> from_unicode ( $utf16 ) eq $locale;
124
return 0 unless $warnings == 1;
129
## Tests if this method is supported:
131
## $utf16 = "\0S\0o\0m\0e";
132
## $Map -> reverse_unicode ( $utf16 );
134
## Proposed substitute for this deprecated usage:
136
## Unicode::String::byteswap ( $utf16 );
139
my $utf16 = "K\0�\0s\0e\0";
141
return 0 unless my $Map = new Unicode::Map ( "ISO-8859-1" );
142
return 0 unless $warnings == 0;
143
$Map -> reverse_unicode ( $utf16 );
144
return 0 unless $warnings == 1;
146
# Has the original variable been changed?
147
return 0 unless $utf16 eq "\0K\0�\0s\0e";
149
# Did we get a transfored copy?
150
return 0 unless $Map -> reverse_unicode ( $utf16 ) eq "K\0�\0s\0e\0";
151
return 0 unless $warnings == 2;
153
# Was it really a copy?
154
return 0 unless $utf16 eq "\0K\0�\0s\0e";
160
## Tests if method "noise" is available:
164
return 0 unless my $Map = new Unicode::Map ( "ISO-8859-1" );
165
return 0 unless $warnings == 0;
167
return 0 unless $warnings == 1;
178
$SIG{'__WARN__'} = sub {
181
$Unicode::Map::WARNINGS = Unicode::Map::WARN_DEPRECATION;
185
$SIG{'__WARN__'} = 0;
187
$Unicode::Map::WARNINGS = Unicode::Map::WARN_DEFAULT;