[libtype-tiny-perl] 11/46: need to split out this test case

Jonas Smedegaard dr at jones.dk
Fri Sep 12 18:48:02 UTC 2014


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

js pushed a commit to tag 1.001_000
in repository libtype-tiny-perl.

commit a109197602029cdcd5255268c2cfd720addbee97
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date:   Thu Aug 28 09:22:35 2014 +0100

    need to split out this test case
---
 t/30-integration/Moose/coercion-more.t | 62 ++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/t/30-integration/Moose/coercion-more.t b/t/30-integration/Moose/coercion-more.t
new file mode 100644
index 0000000..fdf2bfe
--- /dev/null
+++ b/t/30-integration/Moose/coercion-more.t
@@ -0,0 +1,62 @@
+=pod
+
+=encoding utf-8
+
+=head1 PURPOSE
+
+Test for the good old "You cannot coerce an attribute unless its
+type has a coercion" error.
+
+=head1 DEPENDENCIES
+
+Uses the bundled BiggerLib.pm type library.
+
+Test is skipped if Moose 2.1200 is not available.
+
+=head1 AUTHOR
+
+Toby Inkster E<lt>tobyink at cpan.orgE<gt>.
+
+=head1 COPYRIGHT AND LICENCE
+
+This software is copyright (c) 2013-2014 by Toby Inkster.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=cut
+
+use strict;
+use warnings;
+use lib qw( ./lib ./t/lib ../inc ./inc );
+
+use Test::More;
+use Test::Requires { Moose => '2.1200' };
+use Test::Fatal;
+use Test::TypeTiny qw( matchfor );
+
+my $e;
+
+{
+	package Local::Class;
+	
+	use Moose;
+	use BiggerLib -all;
+	
+	::isa_ok(BigInteger, "Moose::Meta::TypeConstraint");
+	
+	has small  => (is => "rw", isa => SmallInteger, coerce => 1);
+	has big    => (is => "rw", isa => BigInteger, coerce => 1);
+	
+	$e = ::exception {
+		has big_nc => (is => "rw", isa => BigInteger->no_coercions, coerce => 1);
+	};
+}
+
+like(
+	$e,
+	qr{^You cannot coerce an attribute .?big_nc.? unless its type .?\w+.? has a coercion},
+	"no_coercions and friends available on Moose type constraint objects",
+);
+
+done_testing;

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



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