[perl-Test-Assert] Tidy the code to pass the Critic test
Paul Howarth
pghmcfc at fedoraproject.org
Thu Jul 10 19:01:58 UTC 2014
commit 2ca22ccf27128546d51b3c4b497816b370c93b61
Author: Paul Howarth <paul at city-fan.org>
Date: Thu Jul 10 20:01:34 2014 +0100
Tidy the code to pass the Critic test
Tidy the code to pass the Critic test even if
Perl::Critic::Policy::ValuesAndExpressions::ProhibitNullStatements is
installed (part of Perl-Critic-Pulp distribution) (#1118374)
Test-Assert-0.0504-Critic.patch | 353 ++++++++++++++++++++++++++++++++++++++-
perl-Test-Assert.spec | 28 ++-
2 files changed, 369 insertions(+), 12 deletions(-)
---
diff --git a/Test-Assert-0.0504-Critic.patch b/Test-Assert-0.0504-Critic.patch
index a569e02..6901ea1 100644
--- a/Test-Assert-0.0504-Critic.patch
+++ b/Test-Assert-0.0504-Critic.patch
@@ -1,10 +1,359 @@
+--- lib/Exception/Assertion.pm
++++ lib/Exception/Assertion.pm
+@@ -128,7 +128,7 @@ class.
+ %ATTRS,
+ },
+ );
+-};
++}
+
+
+ 1;
--- lib/Test/Assert.pm
+++ lib/Test/Assert.pm
-@@ -124,6 +124,7 @@
+@@ -110,7 +110,7 @@ sub import {
+ if ($caller eq 'main') {
+ undef *ASSERT;
+ *ASSERT = sub () { TRUE; };
+- };
++ }
+
+ my @export_ok = ( 'ASSERT', grep { /^(assert_|fail)/ } keys %{ stash(__PACKAGE__) } );
+ my %export_tags = (
+@@ -122,8 +122,9 @@ sub import {
+ OK => \@export_ok,
+ TAGS => \%export_tags,
}, @names);
- };
+-};
++}
+## no critic (ProhibitBuiltinHomonyms)
# Disable debug mode
sub unimport {
+@@ -134,10 +135,10 @@ sub unimport {
+ if ($caller eq 'main') {
+ undef *ASSERT;
+ *ASSERT = sub () { FALSE; };
+- };
++ }
+
+ return unexport_package($caller, $package);
+-};
++}
+
+
+ ## no critic (ProhibitNegativeExpressionsInUnlessAndUntilConditions)
+@@ -158,7 +159,7 @@ sub fail (;$$) {
+
+ assert_false("Should never occured") if ASSERT;
+ return FALSE;
+-};
++}
+
+
+ # Asserts that a condition is true.
+@@ -170,7 +171,7 @@ sub assert_true ($;$) {
+ $self->fail($message, "Expected true value, got undef") unless defined $boolean;
+ $self->fail($message, "Expected true value, got '$boolean'") unless $boolean;
+ return TRUE;
+-};
++}
+
+
+ # Asserts that a condition is false.
+@@ -181,7 +182,7 @@ sub assert_false ($;$) {
+
+ $self->fail($message, "Expected false value, got '$boolean'") unless not $boolean;
+ return TRUE;
+-};
++}
+
+
+ # Asserts that a value is null.
+@@ -192,7 +193,7 @@ sub assert_null ($;$) {
+
+ $self->fail($message, "'$value' is defined") unless not defined $value;
+ return TRUE;
+-};
++}
+
+
+ # Asserts that a value is not null.
+@@ -203,7 +204,7 @@ sub assert_not_null ($;$) {
+
+ $self->fail($message, 'undef unexpected') unless defined $value;
+ return TRUE;
+-};
++}
+
+
+ # Assert that two values are equal
+@@ -225,9 +226,9 @@ sub assert_equals ($$;$) {
+ }
+ else {
+ $self->fail($message, "Expected '$value1', got '$value2'") unless $value1 eq $value2;
+- };
++ }
+ return TRUE;
+-};
++}
+
+
+ # Assert that two values are not equal
+@@ -238,7 +239,7 @@ sub assert_not_equals ($$;$) {
+
+ if (not defined $value1 and not defined $value2) {
+ $self->fail($message, 'Both values were undefined');
+- };
++ }
+ return TRUE if (not defined $value1 xor not defined $value2);
+ if ($value1 =~ /^[+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?$/ and
+ $value2 =~ /^[+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?$/)
+@@ -248,9 +249,9 @@ sub assert_not_equals ($$;$) {
+ }
+ else {
+ $self->fail($message, "'$value1' and '$value2' should differ") unless $value1 ne $value2;
+- };
++ }
+ return TRUE;
+-};
++}
+
+
+ # Assert that two values are numerically equal
+@@ -265,7 +266,7 @@ sub assert_num_equals ($$;$) {
+ $self->fail($message, 'Expected ' . (0+$value1) . ', got undef') if not defined $value2;
+ $self->fail($message, 'Expected ' . (0+$value1) . ', got ' . (0+$value2)) unless $value1 == $value2;
+ return TRUE;
+-};
++}
+
+
+ # Assert that two values are numerically not equal
+@@ -276,12 +277,12 @@ sub assert_num_not_equals ($$;$) {
+ my ($value1, $value2, $message) = @_;
+ if (not defined $value1 and not defined $value2) {
+ $self->fail($message, 'Both values were undefined');
+- };
++ }
+ return TRUE if (not defined $value1 xor not defined $value2);
+ no warnings 'numeric';
+ $self->fail($message, (0+$value1) . ' and ' . (0+$value2) . ' should differ') unless $value1 != $value2;
+ return TRUE;
+-};
++}
+
+
+ # Assert that two strings are equal
+@@ -297,7 +298,7 @@ sub assert_str_equals ($$;$) {
+ $self->fail($message, "Expected '$value1', got undef") unless defined $value2;
+ $self->fail($message, "Expected '$value1', got '$value2'") unless "$value1" eq "$value2";
+ return TRUE;
+-};
++}
+
+
+ # Assert that two strings are not equal
+@@ -308,11 +309,11 @@ sub assert_str_not_equals ($$;$) {
+ my ($value1, $value2, $message) = @_;
+ if (not defined $value1 and not defined $value2) {
+ $self->fail($message, 'Both values were undefined');
+- };
++ }
+ return TRUE if (not defined $value1 xor not defined $value2);
+ $self->fail($message, "'$value1' and '$value2' should differ") unless "$value1" ne "$value2";
+ return TRUE;
+-};
++}
+
+
+ # Assert that string matches regexp
+@@ -330,7 +331,7 @@ sub assert_matches ($$;$) {
+ $self->fail($message, "Expected /$regexp/, got undef") unless defined $value;
+ $self->fail($message, "'$value' didn't match /$regexp/") unless $value =~ $regexp;
+ return TRUE;
+-};
++}
+
+
+ # Assert that string matches regexp
+@@ -348,7 +349,7 @@ sub assert_not_matches ($$;$) {
+ ) unless ref $regexp eq 'Regexp';
+ $self->fail($message, "'$value' matched /$regexp/") unless $value !~ $regexp;
+ return TRUE;
+-};
++}
+
+
+ # Assert that data structures are deeply equal
+@@ -369,7 +370,7 @@ sub assert_deep_equals ($$;$) {
+ ) unless $self->_deep_check($value1, $value2, $data_stack, $seen_refs);
+
+ return TRUE;
+-};
++}
+
+
+ # Assert that data structures are deeply equal
+@@ -390,7 +391,7 @@ sub assert_deep_not_equals ($$;$) {
+ ) unless not $self->_deep_check($value1, $value2, $data_stack, $seen_refs);
+
+ return TRUE;
+-};
++}
+
+
+ # Assert that object is a class
+@@ -407,9 +408,9 @@ sub assert_isa ($$;$) {
+ if (not __isa($value, $class)) {
+ $self->fail($message, "Expected '$class' object or class, got '" . ref($value) . "' reference") if ref $value;
+ $self->fail($message, "Expected '$class' object or class, got '$value' value");
+- };
++ }
+ return TRUE;
+-};
++}
+
+
+ # Assert that object is not a class
+@@ -424,9 +425,9 @@ sub assert_not_isa ($$;$) {
+ ) unless defined $class;
+ if (__isa($value, $class)) {
+ $self->fail($message, "'$value' is a '$class' object or class");
+- };
++ }
+ return TRUE;
+-};
++}
+
+
+ # Assert that code throws an exception
+@@ -456,8 +457,8 @@ sub assert_raises ($&;$) {
+ while ($caught_message =~ s/\t\.\.\.propagated at (?!.*\bat\b.*).* line \d+( thread \d+)?\.\n$//s) { }
+ $caught_message =~ s/( at (?!.*\bat\b.*).* line \d+( thread \d+)?\.)?\n$//s;
+ return TRUE if $caught_message eq $expected;
+- };
+- };
++ }
++ }
+ # Rethrow an exception
+ ## no critic (RequireCarping)
+ die $e;
+@@ -466,9 +467,9 @@ sub assert_raises ($&;$) {
+ $self->fail(
+ $message, 'Expected exception was not raised'
+ );
+- };
++ }
+ return TRUE;
+-};
++}
+
+
+ # Assert that Test::Builder method is ok
+@@ -503,9 +504,9 @@ sub assert_test (&;$) {
+ $self->fail(
+ $new_message, 'assert_test failed'
+ ) unless $ok_return;
+- };
++ }
+ return TRUE;
+-};
++}
+
+
+ # Checks if deep structures are equal
+@@ -516,7 +517,7 @@ sub _deep_check {
+ return TRUE if !defined $e1 && !defined $e2;
+ push @$data_stack, { vals => [$e1, $e2] };
+ return FALSE;
+- };
++ }
+
+ return TRUE if $e1 eq $e2;
+
+@@ -524,7 +525,7 @@ sub _deep_check {
+ my $e2_ref = "$e2";
+ return TRUE if defined $seen_refs->{$e1} && $seen_refs->{$e1} eq $e2_ref;
+ $seen_refs->{$e1} = $e2_ref;
+- };
++ }
+
+ if (ref $e1 eq 'ARRAY' and ref $e2 eq 'ARRAY') {
+ return $self->_eq_array($e1, $e2, $data_stack, $seen_refs);
+@@ -544,10 +545,10 @@ sub _deep_check {
+ }
+ else {
+ push @$data_stack, { vals => [$e1, $e2] };
+- };
++ }
+
+ return FALSE;
+-};
++}
+
+
+ # Checks if arrays are equal
+@@ -568,10 +569,10 @@ sub _eq_array {
+ pop @$data_stack if $ok;
+
+ last unless $ok;
+- };
++ }
+
+ return $ok;
+-};
++}
+
+
+ # Checks if hashes are equal
+@@ -591,10 +592,10 @@ sub _eq_hash {
+ pop @$data_stack if $ok;
+
+ last unless $ok;
+- };
++ }
+
+ return $ok;
+-};
++}
+
+
+ # Dumps the differences for deep structures
+@@ -616,8 +617,8 @@ sub _format_stack {
+ }
+ elsif ($type eq 'REF') {
+ $var = "\${$var}";
+- };
+- };
++ }
++ }
+
+ my @vals = @{$data_stack->[-1]{vals}}[0,1];
+
+@@ -631,13 +632,13 @@ sub _format_stack {
+ $vals[$idx] = !defined $val ? 'undef' :
+ $val eq $DNE ? 'Does not exist'
+ : "'$val'";
+- };
++ }
+
+ $out .= "$vars[0] = $vals[0]\n";
+ $out .= "$vars[1] = $vals[1]";
+
+ return $out;
+-};
++}
+
+
+ # Better, safe "isa" function
+@@ -646,7 +647,7 @@ sub __isa {
+ local $@ = '';
+ local $SIG{__DIE__} = '';
+ return eval { $object->isa($class) };
+-};
++}
+
+
+ no constant::boolean;
diff --git a/perl-Test-Assert.spec b/perl-Test-Assert.spec
index 7a44062..fc5743a 100644
--- a/perl-Test-Assert.spec
+++ b/perl-Test-Assert.spec
@@ -1,24 +1,29 @@
Name: perl-Test-Assert
Version: 0.0504
-Release: 10%{?dist}
+Release: 11%{?dist}
Summary: Assertion methods for those who like JUnit
License: GPL+ or Artistic
Group: Development/Libraries
URL: http://search.cpan.org/dist/Test-Assert/
Source0: http://search.cpan.org/CPAN/authors/id/D/DE/DEXTER/Test-Assert-%{version}.tar.gz
# Upstream signing key, bug #1118362
-Source1: C0B10A5B.pub
+Source1: C0B10A5B.pub
Patch0: Test-Assert-0.0504-Critic.patch
BuildArch: noarch
+BuildRequires: perl
+BuildRequires: perl(Carp)
BuildRequires: perl(Class::Inspector)
BuildRequires: perl(constant)
BuildRequires: perl(constant::boolean) >= 0.02
+BuildRequires: perl(Cwd)
BuildRequires: perl(Exception::Base) >= 0.21
+BuildRequires: perl(File::Spec)
BuildRequires: perl(Module::Build)
BuildRequires: perl(parent)
BuildRequires: perl(strict)
BuildRequires: perl(Symbol::Util) >= 0.0202
-BuildRequires: perl(Test::More)
+BuildRequires: perl(Test::Builder)
+BuildRequires: perl(Test::More) >= 0.88
BuildRequires: perl(Test::Unit::Lite) >= 0.11
BuildRequires: perl(warnings)
# Release test requirements
@@ -28,12 +33,10 @@ BuildRequires: perl(Test::Distribution)
BuildRequires: perl(Test::Kwalitee)
BuildRequires: perl(Test::MinimumVersion)
BuildRequires: perl(Test::Perl::Critic)
-BuildRequires: perl(Test::Pod)
-BuildRequires: perl(Test::Pod::Coverage)
+BuildRequires: perl(Test::Pod) >= 1.14
+BuildRequires: perl(Test::Pod::Coverage) >= 1.04
BuildRequires: perl(Test::Signature)
BuildRequires: perl(Test::Spelling), hunspell-en
-# Release tests does not pass with Perl::Critic::Pulp, bug #1118374
-BuildConflicts: perl(Perl::Critic::Pulp)
Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
# Avoid doc-file dependencies
@@ -51,13 +54,13 @@ cp -a Test-Assert-%{version}/{Changes,eg,LICENSE,README} .
%build
cd Test-Assert-%{version}
-perl Build.PL installdirs=vendor
+perl Build.PL --installdirs=vendor
./Build
cd -
%install
cd Test-Assert-%{version}
-./Build install destdir=%{buildroot} create_packlist=0
+./Build install --destdir=%{buildroot} --create_packlist=0
cd -
%{_fixperms} %{buildroot}
@@ -97,7 +100,7 @@ rm -r "$GNUPGHOME"
[ -f ../MYMETA.yml ] && mv ../MYMETA.yml .
[ -f ../MYMETA.json ] && mv ../MYMETA.json .
-# Patch the code to turn off one check before running the perlcritic test
+# Patch the code to tidy it and turn off one check before running the perlcritic test
patch -p0 < %{P:0}
./Build test --test_files xt/perlcritic.t
patch -p0 -R < %{P:0}
@@ -124,6 +127,11 @@ cd -
%{_mandir}/man3/Test::Assert.3pm*
%changelog
+* Thu Jul 10 2014 Paul Howarth <paul at city-fan.org> - 0.0504-11
+- Tidy the code to pass the Critic test even if
+ Perl::Critic::Policy::ValuesAndExpressions::ProhibitNullStatements is
+ installed (part of Perl-Critic-Pulp distribution) (#1118374)
+
* Thu Jul 10 2014 Petr Pisar <ppisar at redhat.com> - 0.0504-10
- Bundle upstream signing key (bug #1118362)
- Build-conflict with Perl::Critic::Pulp due to release tests (bug #1118374)
More information about the scm-commits
mailing list