Hello community, here is the log from the commit of package perl-Readonly for openSUSE:Factory checked in at 2016-07-03 12:18:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Readonly (Old) and /work/SRC/openSUSE:Factory/.perl-Readonly.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Readonly" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Readonly/perl-Readonly.changes 2016-03-16 10:24:53.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Readonly.new/perl-Readonly.changes 2016-07-03 12:18:28.000000000 +0200 @@ -1,0 +2,28 @@ +Sun Jun 12 13:41:59 UTC 2016 - [email protected] + +- updated to 2.05 + see /usr/share/doc/packages/perl-Readonly/Changes + + 2.05 2016-06-10T17:03:28Z + - Fix deref when using the stupid and utterly unnecessary Readonly::Clone + +------------------------------------------------------------------- +Mon May 23 12:37:09 UTC 2016 - [email protected] + +- updated to 2.04 + see /usr/share/doc/packages/perl-Readonly/Changes + + 2.04 2016-05-07T15:38:37Z + - Quiet compile time warnings about function prototypes and vars being + used only once + + 2.03 2016-05-06T22:27:44Z + - Rewording some documentation + - No longer require an explicit version of perl in META.json or cpanfile + + 2.02 2016-05-06T21:56:10Z + - Create mutable clones of readonly structures with Readonly::Clone + - Still not convinced this is useful but... fixes #13 + - Minor typo patch from Gregor Herrmann <[email protected]> fixes #21 + +------------------------------------------------------------------- Old: ---- Readonly-2.01.tar.gz New: ---- Readonly-2.05.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Readonly.spec ++++++ --- /var/tmp/diff_new_pack.QEs7bw/_old 2016-07-03 12:18:29.000000000 +0200 +++ /var/tmp/diff_new_pack.QEs7bw/_new 2016-07-03 12:18:29.000000000 +0200 @@ -17,7 +17,7 @@ Name: perl-Readonly -Version: 2.01 +Version: 2.05 Release: 0 %define cpan_name Readonly Summary: Facility for creating read-only scalars, arrays, hashes @@ -52,6 +52,6 @@ %files -f %{name}.files %defattr(-,root,root,755) -%doc Changes LICENSE README.md +%doc Changes LICENSE minil.toml README.md %changelog ++++++ Readonly-2.01.tar.gz -> Readonly-2.05.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/Changes new/Readonly-2.05/Changes --- old/Readonly-2.01/Changes 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/Changes 2016-06-10 19:03:44.000000000 +0200 @@ -1,5 +1,21 @@ Revision history for Perl extension Readonly. +2.05 2016-06-10T17:03:28Z + - Fix deref when using the stupid and utterly unnecessary Readonly::Clone + +2.04 2016-05-07T15:38:37Z + - Quiet compile time warnings about function prototypes and vars being + used only once + +2.03 2016-05-06T22:27:44Z + - Rewording some documentation + - No longer require an explicit version of perl in META.json or cpanfile + +2.02 2016-05-06T21:56:10Z + - Create mutable clones of readonly structures with Readonly::Clone + - Still not convinced this is useful but... fixes #13 + - Minor typo patch from Gregor Herrmann <[email protected]> fixes #21 + 2.01 2016-02-24T16:01:12Z - Disallow initialization of Readonly variables by assignment allowed by Perl prototype changes in v5.16. Assignment initialization diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/MANIFEST new/Readonly-2.05/MANIFEST --- old/Readonly-2.01/MANIFEST 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/MANIFEST 2016-06-10 19:03:45.000000000 +0200 @@ -1,12 +1,16 @@ +Build.PL Changes LICENSE +META.json README.md cpanfile eg/benchmark.pl lib/Readonly.pm +minil.toml t/bugs/001_assign.t t/bugs/007_implicit_undef.t t/general/array.t +t/general/clone.t t/general/deepa.t t/general/deeph.t t/general/deeps.t @@ -17,7 +21,5 @@ t/general/reassign.t t/general/scalar.t t/general/tie.t -META.json META.yml -MANIFEST -Build.PL \ No newline at end of file +MANIFEST \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/META.json new/Readonly-2.05/META.json --- old/Readonly-2.01/META.json 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/META.json 2016-06-10 19:03:44.000000000 +0200 @@ -6,7 +6,7 @@ "dynamic_config" : 0, "generated_by" : "Minilla/v3.0.1", "license" : [ - "perl_5" + "artistic_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", @@ -41,11 +41,8 @@ } }, "runtime" : { - "recommends" : { - "perl" : "v5.20.0" - }, "requires" : { - "perl" : "v5.6.0" + "perl" : "5.005" } }, "test" : { @@ -57,7 +54,7 @@ "provides" : { "Readonly" : { "file" : "lib/Readonly.pm", - "version" : "2.01" + "version" : "2.05" }, "Readonly::Array" : { "file" : "lib/Readonly.pm" @@ -80,11 +77,13 @@ "web" : "https://github.com/sanko/readonly" } }, - "version" : "2.01", + "version" : "2.05", "x_contributors" : [ "David Steinbrunner <[email protected]>", "Peter Valdemar Mørch <[email protected]>", - "Ronald Schmidt <[email protected]>" + "vti <[email protected]>", + "Ronald Schmidt <[email protected]>", + "Michael Ivanchenko <[email protected]>" ], "x_serialization_backend" : "JSON::PP version 2.27300" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/META.yml new/Readonly-2.05/META.yml --- old/Readonly-2.01/META.yml 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/META.yml 2016-06-10 19:03:45.000000000 +0200 @@ -8,7 +8,7 @@ Module::Build::Tiny: '0.035' dynamic_config: 0 generated_by: 'Minilla/v3.0.1, CPAN::Meta::Converter version 2.150005' -license: perl +license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' @@ -26,24 +26,24 @@ provides: Readonly: file: lib/Readonly.pm - version: '2.01' + version: '2.05' Readonly::Array: file: lib/Readonly.pm Readonly::Hash: file: lib/Readonly.pm Readonly::Scalar: file: lib/Readonly.pm -recommends: - perl: v5.20.0 requires: - perl: v5.6.0 + perl: '5.005' resources: bugtracker: https://github.com/sanko/readonly/issues homepage: https://github.com/sanko/readonly repository: git://github.com/sanko/readonly.git -version: '2.01' +version: '2.05' x_contributors: - 'David Steinbrunner <[email protected]>' - 'Peter Valdemar Mørch <[email protected]>' + - 'vti <[email protected]>' - 'Ronald Schmidt <[email protected]>' + - 'Michael Ivanchenko <[email protected]>' x_serialization_backend: 'CPAN::Meta::YAML version 0.016' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/README.md new/Readonly-2.05/README.md --- old/Readonly-2.01/README.md 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/README.md 2016-06-10 19:03:44.000000000 +0200 @@ -1,3 +1,4 @@ +[](https://travis-ci.org/sanko/readonly) # NAME Readonly - Facility for creating read-only scalars, arrays, hashes @@ -58,13 +59,34 @@ Readonly has the ability to create both deep and shallow readonly variables. -If any of the values you pass to `Scalar`, `Array`, `Hash`, or the standard -`Readonly` are references, then those functions recurse over the data -structures, marking everything as Readonly. The entire structure is -nonmodifiable. This is normally what you want. +If you pass a `$ref`, an `@array` or a `%hash` to corresponding functions +`::Scalar()`, `::Array()` and `::Hash()`, then those functions recurse over +the data structure, marking everything as readonly. The entire structure is +then non-modifiable. This is normally what you want. + +If you want only the top level to be readonly, use the alternate (and poorly +named) `::Scalar1()`, `::Array1()`, and `::Hash1()` functions. + +Plain `Readonly()` creates what the original author calls a "shallow" +readonly variable, which is great if you don't plan to use it on anything but +only one dimensional scalar values. -If you want only the top level to be Readonly, use the alternate (and poorly -named) `Scalar1`, `Array1`, and `Hash1` functions. +`Readonly::Scalar()` makes the variable 'deeply' readonly, so the following +snippet kills over as you expect: + + use Readonly; + + Readonly::Scalar my $ref => { 1 => 'a' }; + $ref->{1} = 'b'; + $ref->{2} = 'b'; + +While the following snippet does **not** make your structure 'deeply' readonly: + + use Readonly; + + Readonly my $ref => { 1 => 'a' }; + $ref->{1} = 'b'; + $ref->{2} = 'b'; # @@ -257,6 +279,21 @@ $deep[1] = 7; # error $deep[2]{APL}='Weird'; # error, since the hash is Readonly +# Cloning + +When cloning using [Storable](https://metacpan.org/pod/Storable) or [Clone](https://metacpan.org/pod/Clone) you will notice that the value stays +readonly, which is correct. If you want to clone the value without copying the +readonly flag, use the `Clone` function: + + Readonly::Scalar my $scalar => {qw[this that]}; + # $scalar->{'eh'} = 'foo'; # Modification of a read-only value attempted + my $scalar_clone = Readonly::Clone $scalar; + $scalar_clone->{'eh'} = 'foo'; + # $scalar_clone is now {this => 'that', eh => 'foo'}; + +The new variable (`$scalar_clone`) is a mutable clone of the original +`$scalar`. + # Examples These are a few very simple examples: @@ -338,7 +375,7 @@ To 'fix' this, Readonly::XS was written. If installed, Readonly::XS used the internal methods `SvREADONLY` and `SvREADONLY_on` to lock simple scalars. On the surface, everything was peachy but things weren't the same behind the -scenes. In edge cases, code perfromed very differently if Readonly::XS was +scenes. In edge cases, code performed very differently if Readonly::XS was installed and because it wasn't a required dependency in most code, it made downstream bugs very hard to track. @@ -369,9 +406,6 @@ would rather have bugs sent through the issue tracker found at http://github.com/sanko/readonly/issues. -Please check the TODO file included with this distribution in case your bug -is already known (...I probably won't file bug reports to myself). - # Acknowledgements Thanks to Slaven Rezic for the idea of one common function (Readonly) for all @@ -393,7 +427,7 @@ # License and Legal -Copyright (C) 2013, 2014 by Sanko Robinson <[email protected]> +Copyright (C) 2013-2016 by Sanko Robinson <[email protected]> Copyright (c) 2001-2004 by Eric J. Roode. All Rights Reserved. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/cpanfile new/Readonly-2.05/cpanfile --- old/Readonly-2.01/cpanfile 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/cpanfile 2016-06-10 19:03:44.000000000 +0200 @@ -1,4 +1 @@ -recommends 'perl', '5.20.0'; -requires 'perl', '5.6.0'; - -test_requires 'Test::More'; +test_requires 'Test::More'; \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/lib/Readonly.pm new/Readonly-2.05/lib/Readonly.pm --- old/Readonly-2.01/lib/Readonly.pm 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/lib/Readonly.pm 2016-06-10 19:03:44.000000000 +0200 @@ -5,7 +5,7 @@ #use warnings; #no warnings 'uninitialized'; package Readonly; -our $VERSION = '2.01'; +our $VERSION = '2.05'; $VERSION = eval $VERSION; # Autocroak (Thanks, MJD) @@ -18,6 +18,10 @@ # These functions may be overridden by Readonly::XS, if installed. use vars qw/$XSokay/; # Set to true in Readonly::XS, if available +# Predeclare the following, so we can use them recursively +sub _ARRAY (\@); +sub _HASH (\%); + # For perl 5.8.x or higher # These functions are exposed in perl 5.8.x (Thanks, Leon!) # They may be overridden by Readonly::XS, if installed on old perl versions @@ -27,7 +31,7 @@ = sub ($) { die "make_sv_readonly called but not overridden" }; # See if we can use the XS stuff. - $Readonly::XS::MAGIC_COOKIE + $Readonly::XS::MAGIC_COOKIE = $Readonly::XS::MAGIC_COOKIE = "Do NOT use or require Readonly::XS unless you're me."; eval 'use Readonly::XS'; } @@ -38,6 +42,74 @@ $XSokay = 1; # We're using the new built-ins so this is a white lie } +# Undo setting readonly +sub _SCALAR ($) { + my ($r_var) = @_; + if ($XSokay) { + Internals::SvREADONLY($r_var, 0) if is_sv_readonly($r_var); + } + else { + return if tied($r_var) !~ 'Readonly::Scalar'; + my $r_scalar; + { + my $obj = tied $$r_var; + $r_scalar = $obj; + } + untie $r_var; + $r_var = $r_scalar; + } +} + +sub _ARRAY (\@) { + my ($r_var) = @_; + return if !tied(@$r_var); + return if tied(@$r_var) !~ 'Readonly::Array'; + my $r_array; + { + my $obj = tied @$r_var; + $r_array = $obj; + } + untie @$r_var; + @$r_var = @$r_array; + + # Recursively check child elements for references; clean if Readonly + foreach (@$r_var) { + my $_reftype = ref $_; + if ($_reftype eq 'SCALAR') { _SCALAR($_) } + elsif ($_reftype eq 'ARRAY') { + _ARRAY(@$_); + } + elsif ($_reftype eq 'HASH') { + _HASH(%$_); + } + } +} + +sub _HASH (\%) { + my ($r_var) = @_; + return if !tied(%$r_var); + return if tied(%$r_var) !~ 'Readonly::Hash'; + my $r_hash; + { + my $obj = tied %$r_var; + $r_hash = $obj; + } + untie %$r_var; + %$r_var = %$r_hash; + + # Recursively check child elements for references; clean if Readonly + foreach (values %$r_var) { + my $_reftype = ref $_; + if ($_reftype eq 'SCALAR') { _SCALAR($_) } + elsif ($_reftype eq 'ARRAY') { + _ARRAY(@$_); + } + elsif ($_reftype eq 'HASH') { + _HASH(%$_); + } + } +} + # Common error messages, or portions thereof use vars qw/$MODIFY $REASSIGN $ODDHASH/; $MODIFY = 'Modification of a read-only value attempted'; @@ -49,6 +121,11 @@ # ---------------- package Readonly::Scalar; +sub STORABLE_freeze { + my ($self, $cloning) = @_; + Readonly::_SCALAR($$self) if $cloning; +} + sub TIESCALAR { my $whence = (caller 2)[3]; # Check if naughty user is trying to tie directly. @@ -66,13 +143,20 @@ my $self = shift; return $$self; } -*STORE = *UNTIE = sub { Readonly::croak $Readonly::MODIFY}; +*STORE = *STORE = sub { Readonly::croak $Readonly::MODIFY }; +*UNTIE = *UNTIE + = sub { Readonly::croak $Readonly::MODIFY if caller() ne 'Readonly' }; # ---------------- # Read-only arrays # ---------------- package Readonly::Array; +sub STORABLE_freeze { + my ($self, $cloning) = @_; + Readonly::_ARRAY(@$self) if $cloning; +} + sub TIEARRAY { my $whence = (caller 1)[3]; # Check if naughty user is trying to tie directly. @@ -104,13 +188,21 @@ } if $] >= 5.006; # couldn't do "exists" on arrays before then } *STORE = *STORESIZE = *EXTEND = *PUSH = *POP = *UNSHIFT = *SHIFT = *SPLICE - = *CLEAR = *UNTIE = sub { Readonly::croak $Readonly::MODIFY}; + = *CLEAR = *STORE = *STORESIZE = *EXTEND = *PUSH = *POP = *UNSHIFT + = *SHIFT = *SPLICE = *CLEAR = sub { Readonly::croak $Readonly::MODIFY}; +*UNTIE = *UNTIE + = sub { Readonly::croak $Readonly::MODIFY if caller() ne 'Readonly' }; # ---------------- # Read-only hashes # ---------------- package Readonly::Hash; +sub STORABLE_freeze { + my ($self, $cloning) = @_; + Readonly::_HASH(%$self) if $cloning; +} + sub TIEHASH { my $whence = (caller 1)[3]; # Check if naughty user is trying to tie directly. @@ -145,7 +237,10 @@ my $self = shift; return scalar each %$self; } -*STORE = *DELETE = *CLEAR = *UNTIE = sub { Readonly::croak $Readonly::MODIFY}; +*STORE = *DELETE = *CLEAR = *STORE = *DELETE = *CLEAR + = sub { Readonly::croak $Readonly::MODIFY}; +*UNTIE = *UNTIE + = sub { Readonly::croak $Readonly::MODIFY if caller() ne 'Readonly'; }; # ---------------------------------------------------------------- # Main package, containing convenience functions (so callers won't @@ -289,6 +384,25 @@ return tie %$href, 'Readonly::Hash', @values; } +sub Clone(\[$@%]) { + require Storable; + my $retval = Storable::dclone($_[0]); + $retval = $$retval if ref $retval eq 'REF'; + my $reftype = ref $retval; + if ($reftype eq 'SCALAR') { + _SCALAR($retval); + return $$retval; + } + elsif ($reftype eq 'ARRAY') { + _ARRAY(@$retval); + } + elsif ($reftype eq 'HASH') { + _HASH(%$retval); + return %$retval if wantarray; + } + return $retval; +} + # Common entry-point for all supported data types eval q{sub Readonly} . ($] < 5.008 ? '' : '(\[$@%]@)') . <<'SUB_READONLY'; { @@ -396,13 +510,34 @@ Readonly has the ability to create both deep and shallow readonly variables. -If any of the values you pass to C<Scalar>, C<Array>, C<Hash>, or the standard -C<Readonly> are references, then those functions recurse over the data -structures, marking everything as Readonly. The entire structure is -nonmodifiable. This is normally what you want. +If you pass a C<$ref>, an C<@array> or a C<%hash> to corresponding functions +C<::Scalar()>, C<::Array()> and C<::Hash()>, then those functions recurse over +the data structure, marking everything as readonly. The entire structure is +then non-modifiable. This is normally what you want. -If you want only the top level to be Readonly, use the alternate (and poorly -named) C<Scalar1>, C<Array1>, and C<Hash1> functions. +If you want only the top level to be readonly, use the alternate (and poorly +named) C<::Scalar1()>, C<::Array1()>, and C<::Hash1()> functions. + +Plain C<Readonly()> creates what the original author calls a "shallow" +readonly variable, which is great if you don't plan to use it on anything but +only one dimensional scalar values. + +C<Readonly::Scalar()> makes the variable 'deeply' readonly, so the following +snippet kills over as you expect: + + use Readonly; + + Readonly::Scalar my $ref => { 1 => 'a' }; + $ref->{1} = 'b'; + $ref->{2} = 'b'; + +While the following snippet does B<not> make your structure 'deeply' readonly: + + use Readonly; + + Readonly my $ref => { 1 => 'a' }; + $ref->{1} = 'b'; + $ref->{2} = 'b'; =head1 @@ -616,6 +751,21 @@ =back +=head1 Cloning + +When cloning using L<Storable> or L<Clone> you will notice that the value stays +readonly, which is correct. If you want to clone the value without copying the +readonly flag, use the C<Clone> function: + + Readonly::Scalar my $scalar => {qw[this that]}; + # $scalar->{'eh'} = 'foo'; # Modification of a read-only value attempted + my $scalar_clone = Readonly::Clone $scalar; + $scalar_clone->{'eh'} = 'foo'; + # $scalar_clone is now {this => 'that', eh => 'foo'}; + +The new variable (C<$scalar_clone>) is a mutable clone of the original +C<$scalar>. + =head1 Examples These are a few very simple examples: @@ -697,7 +847,7 @@ To 'fix' this, Readonly::XS was written. If installed, Readonly::XS used the internal methods C<SvREADONLY> and C<SvREADONLY_on> to lock simple scalars. On the surface, everything was peachy but things weren't the same behind the -scenes. In edge cases, code perfromed very differently if Readonly::XS was +scenes. In edge cases, code performed very differently if Readonly::XS was installed and because it wasn't a required dependency in most code, it made downstream bugs very hard to track. @@ -734,9 +884,6 @@ would rather have bugs sent through the issue tracker found at http://github.com/sanko/readonly/issues. -Please check the TODO file included with this distribution in case your bug -is already known (...I probably won't file bug reports to myself). - =head1 Acknowledgements Thanks to Slaven Rezic for the idea of one common function (Readonly) for all @@ -758,7 +905,7 @@ =head1 License and Legal -Copyright (C) 2013, 2014 by Sanko Robinson <[email protected]> +Copyright (C) 2013-2016 by Sanko Robinson <[email protected]> Copyright (c) 2001-2004 by Eric J. Roode. All Rights Reserved. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/minil.toml new/Readonly-2.05/minil.toml --- old/Readonly-2.01/minil.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/Readonly-2.05/minil.toml 2016-06-10 19:03:44.000000000 +0200 @@ -0,0 +1,10 @@ +name = "Readonly" +badges = ["travis"] +module_maker="ModuleBuildTiny" +license="artistic_2" + +[release] +pause_config = "C:/Strawberry/pause.upload" + +[ReleaseTest] +MinimumVersion = false \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/t/bugs/001_assign.t new/Readonly-2.05/t/bugs/001_assign.t --- old/Readonly-2.01/t/bugs/001_assign.t 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/t/bugs/001_assign.t 2016-06-10 19:03:44.000000000 +0200 @@ -1,45 +1,44 @@ #!perl -I../../lib # Verify the Readonly function rejects initialization by assignment use strict; -use Test::More tests => 9; - -use constant ASSIGNMENT_ERR => qr/ +use warnings; no warnings 'misc'; +use Test::More; +use Readonly; +# +sub ASSIGNMENT_ERR { + qr/ \QInvalid initialization by assignment\E | # Readonly assignment patch \QType of arg 1 to Readonly::Readonly must be one of\E # pre v5.16 /x; - -# Find the module (1 test) -BEGIN { use_ok('Readonly'); } - -SKIP: -{ - skip 'Readonly $@% syntax is for perl 5.8 or later', 8 unless $] >= 5.008; - -eval 'Readonly my $simple = 2;'; -like $@ => ASSIGNMENT_ERR, 'Reject scalar initialization by assignment'; - -eval 'Readonly my @a = (3, 5);'; -like $@ => ASSIGNMENT_ERR, - 'Reject array initialization by assignment'; - -eval 'Readonly my %h = (key => 42);'; -like $@ => ASSIGNMENT_ERR, - 'Reject hash initialization by assignment'; - -eval 'Readonly my %h = {key => 42};'; -like $@ => ASSIGNMENT_ERR, - 'Reject hash initialization by assignment to hash ref'; - -eval 'Readonly my @a;'; -is $@ => '', 'Readonly empty array OK'; -eval 'Readonly my @a; $a[0] = 2;'; -like $@ => qr/Modification of a read-only/, - 'Readonly empty array is read only'; - -eval 'Readonly my %h;'; -is $@ => '', 'Readonly empty hash OK'; -eval 'Readonly my %h; $h{key} = "v";'; -like $@ => qr/Modification of a read-only/, - 'Readonly empty hash is read only'; - } +SKIP: { + skip 'Readonly $@% syntax is for perl 5.8 or later', 8 unless $] >= 5.008; + # + eval 'Readonly my $simple = 2;'; + like $@ => ASSIGNMENT_ERR, 'Reject scalar initialization by assignment'; + # + eval 'Readonly my @a = (3, 5);'; + like $@ => ASSIGNMENT_ERR, + 'Reject array initialization by assignment'; + # + eval 'Readonly my %h = (key => 42);'; + like $@ => ASSIGNMENT_ERR, + 'Reject hash initialization by assignment'; + # + eval 'Readonly my %h = {key => 42};'; + like $@ => ASSIGNMENT_ERR, + 'Reject hash initialization by assignment to hash ref'; + # + eval 'Readonly my @a;'; + is $@ => '', 'Readonly empty array OK'; + eval 'Readonly my @a; $a[0] = 2;'; + like $@ => qr/Modification of a read-only/, + 'Readonly empty array is read only'; + # + eval 'Readonly my %h;'; + is $@ => '', 'Readonly empty hash OK'; + eval 'Readonly my %h; $h{key} = "v";'; + like $@ => qr/Modification of a read-only/, + 'Readonly empty hash is read only'; +} +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/t/bugs/007_implicit_undef.t new/Readonly-2.05/t/bugs/007_implicit_undef.t --- old/Readonly-2.01/t/bugs/007_implicit_undef.t 2016-02-24 17:01:31.000000000 +0100 +++ new/Readonly-2.05/t/bugs/007_implicit_undef.t 2016-06-10 19:03:44.000000000 +0200 @@ -1,22 +1,21 @@ #!perl -I../../lib # Verify the Readonly function accepts implicit undef values use strict; -use Test::More tests => 3; +use Test::More; +use Readonly; sub expected { my $line = shift; $@ =~ s/\.$//; # difference between croak and die return "Invalid tie at " . __FILE__ . " line $line\n"; } - -# Find the module (1 test) -BEGIN { use_ok('Readonly'); } -SKIP: -{ - skip 'Readonly $@% syntax is for perl 5.8 or later', 1 unless $] >= 5.008; -eval 'Readonly my $simple;'; -is $@ => '', 'Simple API allows for implicit undef values'; +SKIP: { + skip 'Readonly $@% syntax is for perl 5.8 or later', 1 unless $] >= 5.008; + eval 'Readonly my $simple;'; + is $@ => '', 'Simple API allows for implicit undef values'; } eval q'Readonly::Scalar my $scalar;'; like $@ => qr[Not enough arguments for Readonly::Scalar], 'Readonly::Scalar does not allow implicit undef values'; +# +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readonly-2.01/t/general/clone.t new/Readonly-2.05/t/general/clone.t --- old/Readonly-2.01/t/general/clone.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Readonly-2.05/t/general/clone.t 2016-06-10 19:03:44.000000000 +0200 @@ -0,0 +1,53 @@ +# Readonly clone tests +use strict; +use warnings; +use Test::More; +use lib '../../lib'; +use Readonly; +# +Readonly::Scalar my $scalar => 13; +Readonly::Array my @array => (1, 2, 3); +Readonly::Hash my %hash => (foo => 'bar'); +Readonly::Array my @deep_array => (1, \@array); +Readonly::Hash my %deep_hash => (foo => \@array); +# +my $scalar_clone = Readonly::Clone $scalar; +$scalar_clone++; +is $scalar_clone, 14; +# +my @array_clone = Readonly::Clone @array; +$array_clone[1] = 4; +is $array_clone[1], 4; +# +my %hash_clone = Readonly::Clone %hash; +$hash_clone{foo} = 'baz'; +is $hash_clone{foo}, 'baz'; +# +my @deep_array_clone = Readonly::Clone @deep_array; +$deep_array_clone[1]->[2] = 4; +is $deep_array_clone[1]->[2], 4; +# +my %deep_hash_clone = Readonly::Clone %deep_hash; +$deep_hash_clone{foo}->[1] = 4; +is $deep_hash_clone{foo}->[1], 4; +# +{ + Readonly::Scalar my $scalar => ['string']; + my $scalar_clone = Readonly::Clone $scalar; + push @$scalar_clone, 'foo'; + is_deeply $scalar_clone, [qw[string foo]]; +} +{ + Readonly::Scalar my $scalar => {qw[this that]}; + my $scalar_clone = Readonly::Clone $scalar; + $scalar_clone->{'eh'} = 'foo'; + is_deeply $scalar_clone, {this => 'that', eh => 'foo'}; +} +{ + Readonly::Scalar my $scalar => {qw[this that]}; + my %scalar_clone = Readonly::Clone $scalar; + $scalar_clone{'eh'} = 'foo'; + is_deeply [\%scalar_clone], [{this => 'that', eh => 'foo'}]; +} +# +done_testing; ++++++ cpanspec.yml ++++++ --- /var/tmp/diff_new_pack.QEs7bw/_old 2016-07-03 12:18:29.000000000 +0200 +++ /var/tmp/diff_new_pack.QEs7bw/_new 2016-07-03 12:18:29.000000000 +0200 @@ -19,7 +19,7 @@ # rm unused.files #post_install: |- # sed on %{name}.files -#license: SUSE-NonFree +license: Perl License #skip_noarch: 1 #custom_build: |- #./Build build flags=%{?_smp_mflags} --myflag
