Skip to content

Commit

Permalink
Unicode::Normalize: Make ok() common to all .t files
Browse files Browse the repository at this point in the history
There are already two functions designed for the .t files to use whose
common definition is in Normalize.pm

This commit moves the hand-rolled ok() there as well, so its definition
is only in one place.
  • Loading branch information
khwilliamson committed Jul 16, 2021
1 parent 415da10 commit 3cb92df
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 89 deletions.
13 changes: 12 additions & 1 deletion dist/Unicode-Normalize/Normalize.pm
Expand Up @@ -16,7 +16,7 @@ use Carp;

no warnings 'utf8';

our $VERSION = '1.28';
our $VERSION = '1.29';
our $PACKAGE = __PACKAGE__;

our @EXPORT = qw( NFC NFD NFKC NFKD );
Expand Down Expand Up @@ -52,6 +52,17 @@ sub unpack_U {
return unpack('U*', shift(@_).pack('U*'));
}

sub ok ($$;$) {
my $count_ref = shift; # Test number in caller
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}

print $p ? "ok" : "not ok", ' ', ++$$count_ref, "\n";
}

require Exporter;

##### The above part is common to XS and PP #####
Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/fcdc.t
Expand Up @@ -23,14 +23,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..70\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(:all);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/form.t
Expand Up @@ -23,14 +23,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..37\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(:all);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/func.t
Expand Up @@ -23,14 +23,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..217\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(:all);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/illegal.t
Expand Up @@ -43,14 +43,7 @@ use warnings;

BEGIN { $| = 1; print "1..113\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

ok(1);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/norm.t
Expand Up @@ -23,14 +23,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..64\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(normalize);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/partial1.t
Expand Up @@ -31,14 +31,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..26\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(:all);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/partial2.t
Expand Up @@ -31,14 +31,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..26\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(:all);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/proto.t
Expand Up @@ -23,14 +23,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..48\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(:all);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/split.t
Expand Up @@ -31,14 +31,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..34\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize qw(:all);

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/test.t
Expand Up @@ -23,14 +23,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..72\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

use Unicode::Normalize;

Expand Down
9 changes: 1 addition & 8 deletions dist/Unicode-Normalize/t/tie.t
Expand Up @@ -34,14 +34,7 @@ use strict;
use warnings;
BEGIN { $| = 1; print "1..17\n"; }
my $count = 0;
sub ok ($;$) {
my $p = my $r = shift;
if (@_) {
my $x = shift;
$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
}
print $p ? "ok" : "not ok", ' ', ++$count, "\n";
}
sub ok { Unicode::Normalize::ok(\$count, @_) }

ok(1);

Expand Down

0 comments on commit 3cb92df

Please sign in to comment.