1 ################################################################################
3 # !!!!! Do NOT edit this file directly! !!!!!
5 # Edit mktests.PL and/or parts/inc/uv instead.
7 # This file was automatically generated from the definition files in the
8 # parts/inc/ subdirectory by mktests.PL. To learn more about how all this
9 # works, please read the F<HACKERS> file that came with this distribution.
11 ################################################################################
14 if ($ENV{'PERL_CORE'}) {
16 @INC = ('../lib', '../ext/Devel-PPPort/t') if -d '../lib' && -d '../ext';
17 require Config; import Config;
19 if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
20 print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
30 require 'testutil.pl' if $@;
43 package Devel::PPPort;
46 @ISA = qw(DynaLoader);
47 bootstrap Devel::PPPort;
51 BEGIN { require warnings if "$]" > '5.006' }
53 ok(&Devel::PPPort::sv_setuv(42), 42);
54 ok(&Devel::PPPort::newSVuv(123), 123);
55 ok(&Devel::PPPort::sv_2uv("4711"), 4711);
56 ok(&Devel::PPPort::sv_2uv("1735928559"), 1735928559);
57 ok(&Devel::PPPort::SvUVx("1735928559"), 1735928559);
58 ok(&Devel::PPPort::SvUVx(1735928559), 1735928559);
59 ok(&Devel::PPPort::SvUVx(0xdeadbeef), 0xdeadbeef);
60 ok(&Devel::PPPort::XSRETURN_UV(), 42);
61 ok(&Devel::PPPort::PUSHu(), 42);
62 ok(&Devel::PPPort::XPUSHu(), 43);
63 ok(&Devel::PPPort::my_strnlen("abc\0def", 7), 3);
65 # skip tests on 5.6.0 and earlier
66 if ("$]" le '5.006') {
67 skip 'skip: broken utf8 support', 0 for 1..51;
71 ok(&Devel::PPPort::UTF8_SAFE_SKIP("A", 0), 1);
72 ok(&Devel::PPPort::UTF8_SAFE_SKIP("A", -1), 0);
74 my $ret = &Devel::PPPort::utf8_to_uvchr("A");
75 ok($ret->[0], ord("A"));
78 $ret = &Devel::PPPort::utf8_to_uvchr("\0");
82 $ret = &Devel::PPPort::utf8_to_uvchr_buf("A", 0);
83 ok($ret->[0], ord("A"));
86 $ret = &Devel::PPPort::utf8_to_uvchr_buf("\0", 0);
90 if (ord("A") != 65) { # tests not valid for EBCDIC
91 ok(1, 1) for 1 .. (2 + 4 + (7 * 5));
94 $ret = &Devel::PPPort::utf8_to_uvchr_buf("\xc4\x80", 0);
99 local $SIG{__WARN__} = sub { push @warnings, @_; };
102 BEGIN { 'warnings'->import('utf8') if "$]" gt '5.006' }
103 $ret = &Devel::PPPort::utf8_to_uvchr("\xe0\0\x80");
107 BEGIN { 'warnings'->unimport() if "$]" gt '5.006' }
108 $ret = &Devel::PPPort::utf8_to_uvchr("\xe0\0\x80");
109 ok($ret->[0], 0xFFFD);
117 warning => qr/empty/,
118 no_warnings_returned_length => 0,
123 warning => qr/non-continuation/,
124 no_warnings_returned_length => 1,
129 warning => qr/short|1 byte, need 2/,
130 no_warnings_returned_length => 1,
135 warning => qr/overlong|2 bytes, need 1/,
136 no_warnings_returned_length => 2,
139 input => "\xe0\x80\x81",
141 warning => qr/overlong|3 bytes, need 1/,
142 no_warnings_returned_length => 3,
145 input => "\xf0\x80\x80\x81",
147 warning => qr/overlong|4 bytes, need 1/,
148 no_warnings_returned_length => 4,
150 { # Old algorithm failed to detect this
151 input => "\xff\x80\x90\x90\x90\xbf\xbf\xbf\xbf\xbf\xbf\xbf\xbf",
153 warning => qr/overflow/,
154 no_warnings_returned_length => 13,
158 # An empty input is an assertion failure on debugging builds. It is
159 # deliberately the first test.
160 require Config; import Config;
162 if ($Config{ccflags} =~ /-DDEBUGGING/
163 || $^O eq 'VMS' && $Config{usedebugging_perl} eq 'Y') {
168 for my $test (@buf_tests) {
169 my $input = $test->{'input'};
170 my $adjustment = $test->{'adjustment'};
171 my $display = 'utf8_to_uvchr_buf("';
172 for (my $i = 0; $i < length($input) + $adjustment; $i++) {
173 $display .= sprintf "\\x%02x", ord substr($input, $i, 1);
177 my $warning = $test->{'warning'};
180 BEGIN { 'warnings'->import('utf8') if "$]" gt '5.006' }
181 $ret = &Devel::PPPort::utf8_to_uvchr_buf($input, $adjustment);
182 ok($ret->[0], 0, "returned value $display; warnings enabled");
183 ok($ret->[1], -1, "returned length $display; warnings enabled");
184 my $all_warnings = join "; ", @warnings;
185 my $contains = grep { $_ =~ $warning } $all_warnings;
186 ok($contains, 1, $display
187 . "; Got: '$all_warnings', which should contain '$warning'");
190 BEGIN { 'warnings'->unimport('utf8') if "$]" gt '5.006' }
191 $ret = &Devel::PPPort::utf8_to_uvchr_buf($input, $adjustment);
192 ok($ret->[0], 0xFFFD, "returned value $display; warnings disabled");
193 ok($ret->[1], $test->{'no_warnings_returned_length'},
194 "returned length $display; warnings disabled");