[libmoox-late-perl] 02/05: test cases

Intrigeri intrigeri at moszumanska.debian.org
Thu Aug 14 11:13:31 UTC 2014


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to tag 0.001
in repository libmoox-late-perl.

commit d4e66cdf6b27522eba5112ba5a26bc8d27fc2083
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date:   Sat Dec 1 21:45:21 2012 +0000

    test cases
---
 t/01basic.t | 47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/t/01basic.t b/t/01basic.t
index ec78273..04cca88 100644
--- a/t/01basic.t
+++ b/t/01basic.t
@@ -1,3 +1,46 @@
-use Test::More tests => 1;
-BEGIN { use_ok('MooX::late') };
+use strict;
+use warnings;
+use Test::More;
 
+{
+	package Local::Role;
+	use Moo::Role;
+	use MooX::late;
+	has foo => (is => 'ro', isa => 'Str', default => 'foo');
+}
+
+{
+	package Local::Class;
+	use Moo;
+	use MooX::late;
+	with 'Local::Role';
+	has bar => (is => 'ro', isa => 'Str', default => 'bar');
+}
+
+my $o1 = Local::Class->new;
+is($o1->foo, 'foo');
+is($o1->bar, 'bar');
+
+my $o2 = Local::Class->new(foo => 'bar', bar => 'foo');
+is($o2->foo, 'bar');
+is($o2->bar, 'foo');
+
+ok !eval { Local::Class->new(foo => []) };
+ok !eval { Local::Class->new(bar => []) };
+
+{
+	package Local::Other;
+	use Moo;
+	use MooX::late;
+	has foo => (is => 'ro', lazy_build => 1);
+	sub _build_foo { 'foo' };
+}
+
+my $o = Local::Other->new;
+ok( not $o->has_foo );
+is( $o->foo, 'foo' );
+ok( $o->has_foo );
+$o->clear_foo;
+ok( not $o->has_foo );
+
+done_testing;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmoox-late-perl.git



More information about the Pkg-perl-cvs-commits mailing list