[libmoox-late-perl] 03/11: shlomif wants these tests
Intrigeri
intrigeri at moszumanska.debian.org
Thu Aug 14 11:13:46 UTC 2014
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to tag 0.012
in repository libmoox-late-perl.
commit f881708e55c75c16966ae3ecec831613b9b5c1b9
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date: Mon May 13 16:18:15 2013 +0100
shlomif wants these tests
---
t/05haveimissedanytypes.t | 67 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/t/05haveimissedanytypes.t b/t/05haveimissedanytypes.t
new file mode 100644
index 0000000..f42430c
--- /dev/null
+++ b/t/05haveimissedanytypes.t
@@ -0,0 +1,67 @@
+
+use strict;
+use warnings;
+use Test::More;
+
+require Moo;
+
+my @types_to_check = qw(
+ Any
+ Item
+ Bool
+ Maybe
+ Maybe[Int]
+ Undef
+ Defined
+ Value
+ Str
+ Num
+ Int
+ ClassName
+ RoleName
+ Ref
+ ScalarRef
+ ScalarRef[Int]
+ ArrayRef
+ ArrayRef[Int]
+ HashRef
+ HashRef[Int]
+ CodeRef
+ RegexpRef
+ GlobRef
+ FileHandle
+ Object
+);
+
+my $count = 0;
+sub constraint_for
+{
+ my $type = shift;
+ my $class = "Local::Test" . ++$count;
+
+ eval qq{
+ package $class;
+ use Moo;
+ use MooX::late;
+ has attr => (is => "ro", isa => "$type");
+ 1;
+ } or die $@;
+
+ "Moo"->_constructor_maker_for($class)->all_attribute_specs->{attr}{isa};
+}
+
+for my $type (@types_to_check)
+{
+ my $got = constraint_for($type);
+ isa_ok($got, "Type::Tiny", "constraint_for('$type')");
+ is("$got", "$type", "Type constraint returned for '$type' looks right.");
+}
+
+for my $type ("Local::Test1")
+{
+ my $got = constraint_for($type);
+ isa_ok($got, "Type::Tiny::Class", "constraint_for('$type')");
+ is($got->class, $type, "Type constraint returned for '$type' looks right.");
+}
+
+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