use vars '$WARNINGS_ON_BOOTSTRAP';
use vars map "\$${_}_called_PP", qw(BEGIN UNITCHECK CHECK INIT END);
+BEGIN {
+ # This is arguably a hack, but it disposes of the UNITCHECK block without
+ # needing to preprocess the source code
+ if ($] < 5.009) {
+ eval 'sub UNITCHECK (&) {}; 1' or die $@;
+ }
+}
+
# Do these here to verify that XS code and Perl code get called at the same
# times
BEGIN {
}
UNITCHECK {
$UNITCHECK_called_PP++;
-}
+};
{
# Need $W false by default, as some tests run under -w, and under -w we
# can get warnings about "Too late to run CHECK" block (and INIT block)
}
SV*
-my_cxt_getsv_interp(void)
+my_cxt_getsv_interp_context(void)
{
-#ifdef PERL_IMPLICIT_CONTEXT
dTHX;
dMY_CXT_INTERP(my_perl);
-#else
+ return MY_CXT.sv;
+}
+
+SV*
+my_cxt_getsv_interp(void)
+{
dMY_CXT;
-#endif
return MY_CXT.sv;
}
OUTPUT:
RETVAL
+#if defined (hv_common)
+
SV *
common(params)
INPUT:
OUTPUT:
RETVAL
+#endif
+
void
test_hv_free_ent()
PPCODE:
OUTPUT:
RETVAL
+#if PERL_VERSION >= 9
+
bool
refcounted_he_exists(key, level=0)
SV *key
OUTPUT:
RETVAL
-
SV *
refcounted_he_fetch(key, level=0)
SV *key
OUTPUT:
RETVAL
+#endif
=pod
my_cxt_setint_p(aMY_CXT_ i);
void
-my_cxt_getsv()
+my_cxt_getsv(how)
+ bool how;
PPCODE:
EXTEND(SP, 1);
- ST(0) = my_cxt_getsv_interp();
+ ST(0) = how ? my_cxt_getsv_interp_context() : my_cxt_getsv_interp();
XSRETURN(1);
void
{
my %h = (a=>'cheat');
tie %h, 'Tie::StdHash';
- is (XS::APItest::Hash::store(\%h, chr 258, 1), undef);
+ # is bug 36327 fixed?
+ my $result = ($] > 5.009) ? undef : 1;
+
+ is (XS::APItest::Hash::store(\%h, chr 258, 1), $result);
ok (!exists $h{$utf8_for_258},
"hv_store doesn't insert a key with the raw utf8 on a tied hash");
}
-{
+if ($] > 5.009) {
my $strtab = strtab();
is (ref $strtab, 'HASH', "The shared string table quacks like a hash");
my $wibble = "\0";
my $class = tied %$hash;
- my %h1 = @$defaults;
- my %h2 = @$defaults;
+ # It's important to do this with nice new hashes created each time round
+ # the loop, rather than hashes in the pad, which get recycled, and may have
+ # xhv_array non-NULL
+ my $h1 = {@$defaults};
+ my $h2 = {@$defaults};
if (defined $class) {
- tie %h1, ref $class;
- tie %h2, ref $class;
- $HV_STORE_IS_CRAZY = undef;
+ tie %$h1, ref $class;
+ tie %$h2, ref $class;
+ if ($] > 5.009) {
+ # bug 36327 is fixed
+ $HV_STORE_IS_CRAZY = undef;
+ } else {
+ # HV store_ent returns 1 if there was already underlying hash storage
+ $HV_STORE_IS_CRAZY = undef unless @$defaults;
+ }
}
- is (XS::APItest::Hash::store_ent(\%h1, $key, 1), $HV_STORE_IS_CRAZY,
- "hv_store_ent$message $printable");
- ok (brute_force_exists (\%h1, $key), "hv_store_ent$message $printable");
- is (XS::APItest::Hash::store(\%h2, $key, 1), $HV_STORE_IS_CRAZY,
+ is (XS::APItest::Hash::store_ent($h1, $key, 1), $HV_STORE_IS_CRAZY,
+ "hv_store_ent$message $printable");
+ ok (brute_force_exists ($h1, $key), "hv_store_ent$message $printable");
+ is (XS::APItest::Hash::store($h2, $key, 1), $HV_STORE_IS_CRAZY,
"hv_store$message $printable");
- ok (brute_force_exists (\%h2, $key), "hv_store$message $printable");
+ ok (brute_force_exists ($h2, $key), "hv_store$message $printable");
}
sub test_fetch_present {
use warnings;
use strict;
-use Test::More tests => 11;
+use Test::More tests => 16;
BEGIN {
use_ok('XS::APItest');
};
is(my_cxt_getint(), 99, "initial int value");
-is(my_cxt_getsv(), "initial", "initial SV value");
+is(my_cxt_getsv($_), "initial", "initial SV value$_")
+ foreach '', ' (context arg)';
my_cxt_setint(1234);
is(my_cxt_getint(), 1234, "new int value");
my_cxt_setsv("abcd");
-is(my_cxt_getsv(), "abcd", "new SV value");
+is(my_cxt_getsv($_), "abcd", "new SV value$_")
+ foreach '', ' (context arg)';
sub do_thread {
is(my_cxt_getint(), 1234, "initial int value (child)");
my_cxt_setint(4321);
is(my_cxt_getint(), 4321, "new int value (child)");
- is(my_cxt_getsv(), "initial_clone", "initial sv value (child)");
+ is(my_cxt_getsv($_), "initial_clone", "initial sv value (child)$_")
+ foreach '', ' (context arg)';
my_cxt_setsv("dcba");
- is(my_cxt_getsv(), "dcba", "new SV value (child)");
+ is(my_cxt_getsv($_), "dcba", "new SV value (child)$_")
+ foreach '', ' (context arg)';
}
SKIP: {
- skip "No threads", 4 unless $threads;
+ skip "No threads", 6 unless $threads;
threads->create(\&do_thread)->join;
}
is(my_cxt_getint(), 1234, "int value preserved after join");
-is(my_cxt_getsv(), "abcd", "SV value preserved after join");
+is(my_cxt_getsv($_), "abcd", "SV value preserved after join$_")
+ foreach '', ' (context arg)';
print "1..0 # Skip: XS::APItest was not built\n";
exit 0;
}
+ if ($] < 5.009) {
+ print "1..0 # Skip: hints hash not present before 5.10.0\n";
+ exit 0;
+ }
}
use strict;
# I can't see a good way to easily get back perl-space diagnostics for these
# I hope that this isn't a problem.
-ok(sv_setsv_cow_hashkey_core,
- "With PERL_CORE sv_setsv does COW for shared hash key scalars");
+if ($] > 5.009) {
+ ok(sv_setsv_cow_hashkey_core,
+ "With PERL_CORE sv_setsv does COW for shared hash key scalars");
+} else {
+ ok(!sv_setsv_cow_hashkey_core,
+ "With PERL_CORE on 5.8.x sv_setsv doesn't COW for shared hash key scalars");
+}
ok(!sv_setsv_cow_hashkey_notcore,
"Without PERL_CORE sv_setsv doesn't COW for shared hash key scalars");
use strict;
use warnings;
-use Test::More tests => 100;
+my $uc;
+BEGIN {
+ $uc = $] > 5.009;
+}
+use Test::More tests => $uc ? 100 : 80;
# Doing this longhand cut&paste makes it clear
# BEGIN and INIT are FIFO, CHECK and END are LIFO
print "# First BEGIN\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
- is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
- is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called");
+ is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
+ if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called")
+ if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not yet called");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not yet called");
is($XS::APItest::INIT_called, undef, "INIT not yet called");
print "# First CHECK\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, 1, "CHECK called");
is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
is($XS::APItest::INIT_called, undef, "INIT not yet called");
print "# First INIT\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, 1, "CHECK called");
is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
is($XS::APItest::INIT_called, undef, "INIT not yet called");
print "# First END\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, 1, "CHECK called");
is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
is($XS::APItest::INIT_called, 1, "INIT called");
print "# First body\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
-is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
-is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, 1, "CHECK called");
is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
is($XS::APItest::INIT_called, 1, "INIT called");
print "# Second body\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
-is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
-is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, 1, "CHECK called");
is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
is($XS::APItest::INIT_called, 1, "INIT called");
print "# Second BEGIN\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not yet called");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not yet called");
is($XS::APItest::INIT_called, undef, "INIT not yet called");
print "# Second CHECK\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK yet called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK yet called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK yet called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK yet called") if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not yet called");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not yet called");
is($XS::APItest::INIT_called, undef, "INIT not yet called");
print "# Second INIT\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, 1, "CHECK called");
is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
is($XS::APItest::INIT_called, 1, "INIT called");
print "# Second END\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, 1, "CHECK called");
is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
is($XS::APItest::INIT_called, 1, "INIT called");
use strict;
use warnings;
-use Test::More tests => 103;
+my $uc;
+BEGIN {
+ $uc = $] > 5.009;
+}
+use Test::More tests => $uc ? 103 : 83;
# Doing this longhand cut&paste makes it clear
# BEGIN and INIT are FIFO, CHECK and END are LIFO
print "# First BEGIN\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
- is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
- is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called");
+ is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
+ if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
+ if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called");
is($XS::APItest::INIT_called, undef, "INIT not called");
print "# First CHECK\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
- is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
- is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called");
+ is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
+ if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
+ if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
is($XS::APItest::INIT_called, undef, "INIT not called");
print "# First INIT\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
- is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
- is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called");
+ is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
+ if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
+ if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
is($XS::APItest::INIT_called, undef, "INIT not called");
print "# First END\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
print "# First body\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
-is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
-is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called");
+is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called") if $uc;
+is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called") if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
print "# Second body\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
-is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
-is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
print "# Second BEGIN\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
- is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
- is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called");
+ is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
+ if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
+ if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called");
is($XS::APItest::INIT_called, undef, "INIT not called");
print "# Second CHECK\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
- is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
- is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called");
+ is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
+ if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called")
+ if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called");
is($XS::APItest::INIT_called, undef, "INIT not called");
print "# Second INIT\n";
is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
- is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called");
- is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called");
+ is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
+ if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called")
+ if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
print "# Second END\n";
is($XS::APItest::BEGIN_called, 1, "BEGIN called");
is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
- is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called");
- is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called");
+ is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
+ is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
#define START_MY_CXT static my_cxt_t my_cxt;
#define dMY_CXT_SV dNOOP
#define dMY_CXT dNOOP
+#define dMY_CXT_INTERP(my_perl) dNOOP
#define MY_CXT_INIT NOOP
#define MY_CXT_CLONE NOOP
#define MY_CXT my_cxt