Merge branch 'topic/native-trait-bugfix'
[gitmo/Moose.git] / t / 040_type_constraints / 003_util_std_type_constraints.t
index 7c3dae6..20c0f54 100644 (file)
@@ -3,8 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 297;
-use Test::Exception;
+use Test::More;
 
 use Scalar::Util ();
 
@@ -12,6 +11,8 @@ BEGIN {
     use_ok('Moose::Util::TypeConstraints');
 }
 
+my $STRING     = "foo";
+
 my $SCALAR_REF = \(my $var);
 
 no warnings 'once'; # << I *hates* that warning ...
@@ -133,20 +134,20 @@ ok(!defined Ref(undef),           '... Ref rejects anything which is not a Ref')
 
 ok(defined Int(0),                 '... Int accepts anything which is an Int');
 ok(defined Int(100),               '... Int accepts anything which is an Int');
-ok(!defined Int(0.5),              '... Int accepts anything which is not a Int');
-ok(!defined Int(100.01),           '... Int accepts anything which is not a Int');
-ok(!defined Int(''),               '... Int rejects anything which is not a Int');
-ok(!defined Int('Foo'),            '... Int rejects anything which is not a Int');
-ok(!defined Int([]),               '... Int rejects anything which is not a Int');
-ok(!defined Int({}),               '... Int rejects anything which is not a Int');
-ok(!defined Int(sub {}),           '... Int rejects anything which is not a Int');
-ok(!defined Int($SCALAR_REF),      '... Int rejects anything which is not a Int');
-ok(!defined Int($GLOB),            '... Int rejects anything which is not a Int');
-ok(!defined Int($GLOB_REF),        '... Int rejects anything which is not a Int');
-ok(!defined Int($fh),              '... Int rejects anything which is not a Int');
-ok(!defined Int(qr/../),           '... Int rejects anything which is not a Int');
-ok(!defined Int(bless {}, 'Foo'),  '... Int rejects anything which is not a Int');
-ok(!defined Int(undef),            '... Int rejects anything which is not a Int');
+ok(!defined Int(0.5),              '... Int accepts anything which is not an Int');
+ok(!defined Int(100.01),           '... Int accepts anything which is not an Int');
+ok(!defined Int(''),               '... Int rejects anything which is not an Int');
+ok(!defined Int('Foo'),            '... Int rejects anything which is not an Int');
+ok(!defined Int([]),               '... Int rejects anything which is not an Int');
+ok(!defined Int({}),               '... Int rejects anything which is not an Int');
+ok(!defined Int(sub {}),           '... Int rejects anything which is not an Int');
+ok(!defined Int($SCALAR_REF),      '... Int rejects anything which is not an Int');
+ok(!defined Int($GLOB),            '... Int rejects anything which is not an Int');
+ok(!defined Int($GLOB_REF),        '... Int rejects anything which is not an Int');
+ok(!defined Int($fh),              '... Int rejects anything which is not an Int');
+ok(!defined Int(qr/../),           '... Int rejects anything which is not an Int');
+ok(!defined Int(bless {}, 'Foo'),  '... Int rejects anything which is not an Int');
+ok(!defined Int(undef),            '... Int rejects anything which is not an Int');
 
 ok(defined Num(0),                 '... Num accepts anything which is an Num');
 ok(defined Num(100),               '... Num accepts anything which is an Num');
@@ -169,6 +170,7 @@ ok(defined Str(0),                 '... Str accepts anything which is a Str');
 ok(defined Str(100),               '... Str accepts anything which is a Str');
 ok(defined Str(''),                '... Str accepts anything which is a Str');
 ok(defined Str('Foo'),             '... Str accepts anything which is a Str');
+ok(defined Str(substr($STRING,0,1)),'... Str accepts anything which is a Str');
 ok(!defined Str([]),               '... Str rejects anything which is not a Str');
 ok(!defined Str({}),               '... Str rejects anything which is not a Str');
 ok(!defined Str(sub {}),           '... Str rejects anything which is not a Str');
@@ -188,6 +190,7 @@ ok(!defined ScalarRef([]),               '... ScalarRef rejects anything which i
 ok(!defined ScalarRef({}),               '... ScalarRef rejects anything which is not a ScalarRef');
 ok(!defined ScalarRef(sub {}),           '... ScalarRef rejects anything which is not a ScalarRef');
 ok(defined ScalarRef($SCALAR_REF),       '... ScalarRef accepts anything which is a ScalarRef');
+ok(defined ScalarRef(\$SCALAR_REF),      '... ScalarRef accepts references to references');
 ok(!defined ScalarRef($GLOB),            '... ScalarRef rejects anything which is not a ScalarRef');
 ok(!defined ScalarRef($GLOB_REF),        '... ScalarRef rejects anything which is not a ScalarRef');
 ok(!defined ScalarRef($fh),              '... ScalarRef rejects anything which is not a ScalarRef');
@@ -356,3 +359,5 @@ ok(!defined RoleName('Moose::Meta::TypeConstraint'),  '... RoleName accepts anyt
 ok(defined RoleName('Quux::Wibble::Role'),      '... RoleName accepts anything which is a RoleName');
 
 close($fh) || die "Could not close the filehandle $0 for test";
+
+done_testing;