}
}
-my ($plan, $test, $failed, $no_diag);
+my $TAP_STREAM = *STDOUT;
+my $DIAG_STREAM = *STDERR;
+
+my ($plan, $test, $failed, $no_diag, $done_testing);
sub NO_PLAN () { -1 }
sub SKIP_ALL () { -2 }
BEGIN {
- threads::shared::share($plan), lock $plan if THREADSAFE;
+ if (THREADSAFE) {
+ threads::shared::share($_) for $plan, $test, $failed, $no_diag;
+ }
+
+ lock $plan if THREADSAFE;
$plan = undef;
$test = 0;
$failed = 0;
}
-my $TAP_STREAM = *STDOUT;
-my $DIAG_STREAM = *STDERR;
-
sub carp {
my $level = 1 + ($Test::Builder::Level || 0);
my ($file, $line) = (caller $level)[1, 2];
ok
is
isnt
+ cmp_ok
like
unlike
diag
last SKIP;
}
-my $done_testing;
-
sub done_testing {
my ($count) = @_;
eval <<"IS_BINOP";
sub is_$name (\$\$;\$) {
my (\$x, \$y, \$desc) = \@_;
- no warnings 'uninitialized';
- \@_ = (
- (not(defined \$x xor defined \$y) and \$x $op \$y),
- \$desc,
- );
+ \@_ = ((\$x $op \$y), \$desc);
goto &ok;
}
IS_BINOP
}
}
-{
- no warnings 'once';
- *is = \&is_eq;
- *like = \&is_like;
- *unlike = \&is_unlike;
+sub is ($$;$) {
+ my ($got, $expected, $desc) = @_;
+ no warnings 'uninitialized';
+ @_ = (
+ (not(defined $got xor defined $expected) and $got eq $expected),
+ $desc,
+ );
+ goto &ok;
}
sub isnt ($$;$) {
goto &ok;
}
+{
+ no warnings 'once';
+ *like = \&is_like;
+ *unlike = \&is_unlike;
+}
+
sub cmp_ok ($$$;$) {
my ($x, $op, $y, $desc) = @_;
my $name = $binops{$op};
croak("Operator $op not supported") unless defined $name;
@_ = ($x, $y, $desc);
no strict 'refs';
- goto &{__PACKAGE__."is_$name"};
+ goto &{__PACKAGE__."::is_$name"};
}
sub _diag_fh {