1#!/usr/bin/perl 2# $File: /member/local/autrijus/encoding-warnings//t/1-warning.t $ $Author: autrijus $ 3# $Revision: #5 $ $Change: 6145 $ $DateTime: 2004-07-16T03:49:06.717424Z $ 4 5BEGIN { 6 if (ord("A") != 65) { 7 print "1..0 # Skip: Encode not working on EBCDIC\n"; 8 exit 0; 9 } 10 unless (eval { require Encode } ) { 11 print "1..0 # Skip: no Encode\n"; 12 exit 0; 13 } 14} 15 16use Test; 17use strict; 18 19BEGIN { 20 if ("$]" >= 5.025) { 21 # Test the new almost-noop behaviour in new perls. 22 plan tests => 3; 23 my $w; 24 $SIG{__WARN__} = sub { $w .= shift }; 25 require encoding::warnings; 26 ok $w, undef, 'no warning from requiring encoding::warnings'; 27 ok(encoding::warnings->VERSION); 28 encoding::warnings->import; 29 ok $w, qr/^encoding::warnings is not supported /, 'import warning'; 30 exit; 31 } 32 # else continue with your usual scheduled testing... 33 plan tests => 2; 34} 35 36use encoding::warnings; 37ok(encoding::warnings->VERSION); 38 39if ($] < 5.008) { 40 ok(1); 41 exit; 42} 43 44my ($a, $b, $c, $ok); 45 46$SIG{__WARN__} = sub { 47 if ($_[0] =~ /upgraded/) { ok(1); exit } 48}; 49 50utf8::encode($a = chr(20000)); 51$b = chr(20000); 52$c = $a . $b; 53 54ok($ok); 55 56__END__ 57