Revision history for Mouse
+0.50_05 Sat Feb 27 20:37:15 2010
+ * Moose::Util::TypeConstraints
+ - Moose used an incorrect cast at the C-level which meant that
+ its idea of numbers was different from that of Perl's (and
+ Moose's). Notably > 2**32 Integers on 32 bit systems didn't
+ work.
+
0.50_04 Fri Feb 26 18:57:24 2010
* All
- Warnings are less noisy, as shown by example/warns.pl (gfx)
--- /dev/null
+package MyInteger;
+use Mouse;
+
+has a_int => (
+ is => 'rw',
+ isa => 'Int',
+);
+
+has a_num => (
+ is => 'rw',
+ isa => 'Num',
+);
+
+package main;
+use Test::More tests => 212 * 2;
+
+for (my $i = 1; $i <= 10e100; $i += $i * 2) {
+ my $int = MyInteger->new( a_int => $i )->a_int;
+ cmp_ok($int, '==', $i, "Mouse groked the Int $i");
+
+ my $num = MyInteger->new( a_num => $i )->a_num;
+ cmp_ok($num, '==', $i, "Mouse groked the Num $i");
+}
int
mouse_tc_Int(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
assert(sv);
- if(SvIOKp(sv)){
+ if(SvIOKp(sv) || SvNOKp(sv)){
return TRUE;
}
- else if(SvNOKp(sv)){
- NV const nv = SvNVX(sv);
- return nv > 0 ? (nv == (NV)(UV)nv) : (nv == (NV)(IV)nv);
- }
else if(SvPOKp(sv)){
int const num_type = grok_number(SvPVX(sv), SvCUR(sv), NULL);
if(num_type){