This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove all space optimisations from SV body structures.
[perl5.git] / dist / I18N-LangTags / t / 55_supers_strict.t
CommitLineData
8000a3fa
RGS
1
2# Time-stamp: "2004-03-30 17:49:58 AST"
3#sub I18N::LangTags::Detect::DEBUG () {10}
4use I18N::LangTags qw(implicate_supers_strictly);
5
6use Test;
7BEGIN { plan tests => 19 };
8
9print "#\n# Testing strict (non-tight) insertion of super-ordinate language tags...\n#\n";
10
11my @in = grep m/\S/, split /[\n\r]/, q{
12 NIX => NIX
13 sv => sv
14 en => en
15 hai => hai
16
17 pt-br => pt-br pt
18 pt-br fr => pt-br fr pt
19 pt-br fr pt => pt-br fr pt
20 pt-br fr pt de => pt-br fr pt de
21 de pt-br fr pt => de pt-br fr pt
22 de pt-br fr => de pt-br fr pt
23 hai pt-br fr => hai pt-br fr pt
24
25# Now test multi-part complicateds:
26 pt-br-janeiro fr => pt-br-janeiro fr pt-br pt
27pt-br-janeiro de fr => pt-br-janeiro de fr pt-br pt
28pt-br-janeiro de pt fr => pt-br-janeiro de pt fr pt-br
29
30ja pt-br-janeiro fr => ja pt-br-janeiro fr pt-br pt
31ja pt-br-janeiro de fr => ja pt-br-janeiro de fr pt-br pt
32ja pt-br-janeiro de pt fr => ja pt-br-janeiro de pt fr pt-br
33
34pt-br-janeiro de pt-br fr => pt-br-janeiro de pt-br fr pt
35 # an odd case, since we don't filter for uniqueness in this sub
36
37};
38
39
40foreach my $in (@in) {
41 $in =~ s/^\s+//s;
42 $in =~ s/\s+$//s;
43 $in =~ s/#.+//s;
44 next unless $in =~ m/\S/;
45
46 my(@in, @should);
47 {
48 die "What kind of line is <$in>?!"
49 unless $in =~ m/^(.+)=>(.+)$/s;
50
51 my($i,$s) = ($1, $2);
52 @in = ($i =~ m/(\S+)/g);
53 @should = ($s =~ m/(\S+)/g);
54 #print "{@in}{@should}\n";
55 }
56 my @out = I18N::LangTags::implicate_supers_strictly(
57 ("@in" eq 'NIX') ? () : @in
58 );
59 #print "O: ", join(' ', map "<$_>", @out), "\n";
60 @out = 'NIX' unless @out;
61
62
63 if( @out == @should
64 and lc( join "\e", @out ) eq lc( join "\e", @should )
65 ) {
66 print "# Happily got [@out] from [$in]\n";
67 ok 1;
68 } else {
69 ok 0;
70 print "#!!Got: [@out]\n",
71 "#!! but wanted: [@should]\n",
72 "#!! from \"$in\"\n#\n";
73 }
74}
75
76print "#\n#\n# Bye-bye!\n";
77ok 1;
78