@@ -1,5 +1,9 @@
Release history for Object-Tiny-Lvalue
+1.083 Thu 19 Mar 2015
+ - No functional changes
+ - Further test suite cleanup
+
1.082 Sat 10 Jan 2015
- No functional changes
- No longer contains INSTALL file with install-as-root instructions
@@ -9,5 +9,7 @@ README
dist.ini
lib/Object/Tiny/Lvalue.pm
t/00-compile.t
-t/main.t
-t/subclass.t
+t/lib/PlainClass.pm
+t/lib/SomeClass.pm
+t/lib/SubClass.pm
+t/object_tiny_lvalue.t
@@ -30,7 +30,11 @@
"requires" : {
"File::Find" : "0",
"File::Temp" : "0",
- "Test::More" : "0.88"
+ "Test::Fatal" : "0",
+ "Test::Lives" : "0",
+ "Test::More" : "0.88",
+ "lib" : "0",
+ "parent" : "0"
}
}
},
@@ -45,6 +49,6 @@
"url" : "git://github.com/ap/Object-Tiny-Lvalue"
}
},
- "version" : "1.082"
+ "version" : "1.083"
}
@@ -5,7 +5,11 @@ author:
build_requires:
File::Find: 0
File::Temp: 0
+ Test::Fatal: 0
+ Test::Lives: 0
Test::More: 0.88
+ lib: 0
+ parent: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 0
@@ -23,4 +27,4 @@ resources:
bugtracker: http://github.com/ap/Object-Tiny-Lvalue/issues
homepage: http://github.com/ap/Object-Tiny-Lvalue
repository: git://github.com/ap/Object-Tiny-Lvalue
-version: 1.082
+version: 1.083
@@ -27,9 +27,13 @@ my %WriteMakefileArgs = (
"TEST_REQUIRES" => {
"File::Find" => 0,
"File::Temp" => 0,
- "Test::More" => "0.88"
+ "Test::Fatal" => 0,
+ "Test::Lives" => 0,
+ "Test::More" => "0.88",
+ "lib" => 0,
+ "parent" => 0
},
- "VERSION" => "1.082",
+ "VERSION" => "1.083",
"test" => {
"TESTS" => "t/*.t"
}
@@ -40,7 +44,11 @@ my %FallbackPrereqs = (
"ExtUtils::MakeMaker" => 0,
"File::Find" => 0,
"File::Temp" => 0,
+ "Test::Fatal" => 0,
+ "Test::Lives" => 0,
"Test::More" => "0.88",
+ "lib" => 0,
+ "parent" => 0,
"strict" => 0,
"warnings" => 0
);
@@ -3,6 +3,8 @@ Object::Tiny::Lvalue
This is a clone of Object::Tiny, but adjusted to create accessors that
return lvalues.
+You probably want to use Object::Properties instead.
+
INSTALLATION
This is a Perl module distribution. It should be installed with whichever
@@ -1,5 +1,5 @@
name = Object-Tiny-Lvalue
-version = 1.082
+version = 1.083
author = Aristotle Pagaltzis <pagaltzis@gmx.de>
license = Perl_5
copyright_holder = Aristotle Pagaltzis
@@ -3,7 +3,7 @@ use strict;
use warnings;
package Object::Tiny::Lvalue;
-$Object::Tiny::Lvalue::VERSION = '1.082';
+$Object::Tiny::Lvalue::VERSION = '1.083';
# ABSTRACT: minimal class builder with lvalue accessors
sub import {
@@ -40,7 +40,7 @@ Object::Tiny::Lvalue - minimal class builder with lvalue accessors
=head1 VERSION
-version 1.082
+version 1.083
=head1 SYNOPSIS
@@ -61,6 +61,8 @@ Use the class:
This is a clone of L<Object::Tiny|Object::Tiny>, but adjusted to create accessors that return lvalues.
+You probably want to use L<Object::Properties|Object::Properties> instead.
+
=head1 AUTHOR
Aristotle Pagaltzis <pagaltzis@gmx.de>
@@ -0,0 +1,6 @@
+package # hide from PAUSE
+ PlainClass;
+
+sub new { my $class = shift; bless { @_ }, $class }
+
+1;
@@ -0,0 +1,6 @@
+package # hide from PAUSE
+ SomeClass;
+
+use Object::Tiny::Lvalue qw( foo bar );
+
+1;
@@ -0,0 +1,7 @@
+package # hide from PAUSE
+ SubClass;
+
+use parent 'PlainClass';
+use Object::Tiny::Lvalue qw( foo bar );
+
+1;
@@ -1,47 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More 0.88; # for done_testing
-
-# Define a class
-SCOPE: {
- eval "
- package Foo;
-
- use Object::Tiny::Lvalue qw( foo bar );
- ";
- ok( ! $@, 'Created package without error' );
-}
-
-# Create a trivial object
-SCOPE: {
- my $empty = Foo->new;
- isa_ok( $empty, 'Foo' );
- isa_ok( $empty, 'Object::Tiny::Lvalue' );
- is( scalar( keys %$empty ), 0, 'Empty object is empty' );
-}
-
-# Create a real object
-SCOPE: {
- my $object = Foo->new( foo => 1, bar => 2, baz => 3 );
- isa_ok( $object, 'Foo' );
- isa_ok( $object, 'Object::Tiny::Lvalue' );
- is( scalar( keys %$object ), 3, 'Object contains expect elements' );
- is( $object->foo, 1, '->foo ok' );
- is( $object->bar, 2, '->bar ok' );
- eval {
- $object->baz;
- };
- ok( $@, '->baz returns an error' );
- is( $object->{baz}, 3, '->{baz} does contain value' );
- $object->foo = 42;
- is( $object->foo, 42, '->foo(new_value) ok' );
-}
-
-# Trigger the constructor exception
-SCOPE: {
- eval "package Bar; use Object::Tiny::Lvalue 'bad thing';";
- ok( $@ =~ /Invalid accessor name/, 'Got expected error' );
-}
-
-done_testing;
@@ -0,0 +1,51 @@
+use strict;
+use warnings;
+
+use Test::More 0.88; # for done_testing
+use Test::Fatal;
+use Test::Lives;
+
+use lib 't/lib';
+
+require_ok 'SomeClass';
+
+for my $obj ( SomeClass->new ) {
+ isa_ok $obj, 'SomeClass';
+ isa_ok $obj, 'Object::Tiny::Lvalue';
+ is 0+keys %$obj, 0, 'Empty object is empty';
+}
+
+for my $obj ( SomeClass->new( foo => 1, bar => 2, baz => 3 ) ) {
+ isa_ok $obj, 'SomeClass';
+ isa_ok $obj, 'Object::Tiny::Lvalue';
+ is 0+keys %$obj, 3, 'It has the right number of keys';
+ is $obj->{'foo'}, 1, '... with correct value for "foo"';
+ is $obj->{'bar'}, 2, '... and "bar"';
+ is $obj->{'baz'}, 3, '... and "baz"';
+
+ lives_and { is $obj->foo, 1, $_ } 'Accessors exist and give the expected answers';
+ lives_and { is $obj->bar, 2, $_ } '... for declared fields';
+ like exception { $obj->baz }, qr/locate object method/, '... but not for other keys';
+
+ lives_and { $obj->foo = 42; is $obj->foo, 42, $_ } 'Read-write accessors can be written to';
+}
+
+like exception { package Foo; Object::Tiny::Lvalue->import( 'bad identifier' ) },
+ qr/Invalid accessor name/, 'Bad identifiers are rejected';
+
+require_ok 'SubClass';
+
+for my $obj ( SubClass->new( foo => 1, bar => 2, baz => 3 ) ) {
+ isa_ok $obj, 'SubClass';
+ isa_ok $obj, 'PlainClass';
+ is $obj->isa( 'Object::Tiny::Lvalue' ), !1, '@ISA is only touched if non-empty';
+ is 0+keys %$obj, 3, 'It has the right number of keys';
+ is $obj->{'foo'}, 1, '... with correct value for "foo"';
+ is $obj->{'bar'}, 2, '... and "bar"';
+ is $obj->{'baz'}, 3, '... and "baz"';
+ lives_and { is $obj->foo, 1, $_ } 'Accessors exist and give the expected answers';
+ lives_and { is $obj->bar, 2, $_ } '... for declared fields';
+ like exception { $obj->baz }, qr/locate object method/, '... but not for other keys';
+}
+
+done_testing;
@@ -1,49 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More 0.88; # for done_testing
-
-# Define a class
-SCOPE: {
- eval "
- package Bar;
-
- sub new {
- my \$class = shift;
- return bless { \@_ }, \$class;
- }
-
- package Foo;
-
- \@Foo::ISA = 'Bar';
-
- use Object::Tiny::Lvalue qw( foo bar );
- ";
- ok( ! $@, 'Created package without error' );
-}
-
-# Create a trivial object
-SCOPE: {
- my $empty = Foo->new;
- isa_ok( $empty, 'Foo' );
- isa_ok( $empty, 'Bar' );
- ok( ! $empty->isa('Object::Tiny::Lvalue'), 'Is not an Object::Tiny::Lvalue' );
- is( scalar( keys %$empty ), 0, 'Empty object is empty' );
-}
-
-# Create a real object
-SCOPE: {
- my $object = Foo->new( foo => 1, bar => 2, baz => 3 );
- isa_ok( $object, 'Foo' );
- isa_ok( $object, 'Bar' );
- is( scalar( keys %$object ), 3, 'Object contains expect elements' );
- is( $object->foo, 1, '->foo ok' );
- is( $object->bar, 2, '->bar ok' );
- eval {
- $object->baz;
- };
- ok( $@, '->bar returns an error' );
- is( $object->{baz}, 3, '->{baz} does contain value' );
-}
-
-done_testing;