Dios
view release on metacpan or search on metacpan
lib/Dios/Types.pm view on Meta::CPAN
Accepts any value is defined...but not a reference.
For example: C<7> or C<0x093FA3D7> or C<'word'>.
=head3 C<< Num >>
Accepts any value that is defined and also something for which
C<Scalar::Util::looks_like_number()> returns true.
However, unlike C<looks_like_number()>, this type does B<not> accept the
special value C<'NaN'>. (I mean, what part of "I<not> a number" does
that function not understand???)
Note that this type B<does> accept other special values like
"Inf"/"Infinity", as well as objects with numeric overloadings.
=head3 C<< Int >>
Accepts any value for which C<Scalar::Util::looks_like_number()> returns
true I<and> which also matches the regex:
lib/Dios/Types/Pure.pm view on Meta::CPAN
Accepts any value is defined...but not a reference.
For example: C<7> or C<0x093FA3D7> or C<'word'>.
=head3 C<< Num >>
Accepts any value that is defined and also something for which
C<Scalar::Util::looks_like_number()> returns true.
However, unlike C<looks_like_number()>, this type does B<not> accept the
special value C<'NaN'>. (I mean, what part of "I<not> a number" does
that function not understand???)
Note that this type B<does> accept other special values like
"Inf"/"Infinity", as well as objects with numeric overloadings.
=head3 C<< Int >>
Accepts any value for which C<Scalar::Util::looks_like_number()> returns
true I<and> which also matches the regex:
t/types_basic.t view on Meta::CPAN
type_okay( \$i, 'Ref[Num]' );
type_fail( \$s, 'Ref[Int]' );
type_fail( \$f, 'Ref[Int]' );
type_okay( \$i, 'Ref[Int]' );
SKIP: {
skip "requires Perl 5.8", 3 if $] < 5.008;
type_okay( "Inf", 'Num');
type_okay( "-Inf", 'Num');
type_fail( "NaN", 'Num');
type_okay( "Inf", 'Int');
type_okay( "-Inf", 'Int');
type_fail( "NaN", 'Int');
}
my @VALID_NUMS = qw(
0 0e123 0e+123 0e-123
+0 +0e123 +0e+123 +0e-123
-0 -0e123 -0e+123 -0e-123
0.12 0.12e123 0.12e+123 0.12e-123
+0.12 +0.12e123 +0.12e+123 +0.12e-123
-0.12 -0.12e123 -0.12e+123 -0.12e-123
t/types_basic_validator.t view on Meta::CPAN
type_okay( \$i, 'Ref[Num]' );
type_fail( \$s, 'Ref[Int]' );
type_fail( \$f, 'Ref[Int]' );
type_okay( \$i, 'Ref[Int]' );
SKIP: {
skip "requires Perl 5.8", 3 if $] < 5.008;
type_okay( "Inf", 'Num');
type_okay( "-Inf", 'Num');
type_fail( "NaN", 'Num');
type_okay( "Inf", 'Int');
type_okay( "-Inf", 'Int');
type_fail( "NaN", 'Int');
}
my @VALID_NUMS = qw(
0 0e123 0e+123 0e-123
+0 +0e123 +0e+123 +0e-123
-0 -0e123 -0e+123 -0e-123
0.12 0.12e123 0.12e+123 0.12e-123
+0.12 +0.12e123 +0.12e+123 +0.12e-123
-0.12 -0.12e123 -0.12e+123 -0.12e-123
( run in 0.667 second using v1.01-cache-2.11-cpan-4d50c553e7e )