Data-Util
view release on metacpan or search on metacpan
0.43 Sun Dec 14 13:37:43 2008
- fix modifer's order of modify_subroutine()/subroutine_modifier()
to be compatible with Moose
- fix some bugs on neat()/is_number()/install_subroutine()
- remove "original" property from subroutine_modifier(), which seems
a waste of memory
- internal cleanup
0.42 Wed Dec 10 13:42:50 2008
- fix is_number()/is_integer() to refuse Infinity and NaN correctly
- fix a possible segfault on install_subrouitne()
- internal cleanup
0.41 Man Dec 8 11:36:38 2008
- change get_stash() to be able to take an object reference
- change is_number()/is_integer() to refuse "0 but true"
- fix some bugs
0.40 Sun Dec 7 13:42:17 2008
- add is_value()/is_string()/is_number()/is_integer() functions
lib/Data/Util/JA.pod view on Meta::CPAN
ãã®é¢æ°ã«ã¯æ¤è¨¼ãè¡ã対å¿é¢æ°ãããã¾ããã
=item is_number(value)
I<value>ãæ°å¤ãã©ããããã§ãã¯ãã¾ãã
ããã§B<æ°å¤>ã¨ã¯ï¼æ°å¤ã³ã³ããã¹ã(ãã¨ãã°C<< sprintf '%g', $value >>ï¼
ã§è¦åãåºããã«æ°å¤ã«å¤æå¯è½ã§ããï¼
ãã¤Perlããã°ã©ã ä¸ã«ãªãã©ã«ã¨ãã¦ãããã¨ãã§ããå¤ã¨ããæå³ã§ãã
ããªãã¡ï¼ãã®é¢æ°ã¯C<Scalar::Util::looks_like_number()>ã¨ç°ãªãï¼
C<Infinity>ãC<NaN>ã¯ãªãã©ã«ã¨ãã¦ããã°ã©ã ä¸ã«ç½®ããã¨ã¯ã§ããªãããï¼
æ°å¤ã¨ãã¦æ±ãã¾ãããã¾ãï¼æ°å¤åããã¨ãã«è¦åãåºããªãä¾å¤ã§ãã
C<"0 but true">ãåãçç±ã§æ°å¤ã¨ãã¦æ±ãã¾ããã
ãã®é¢æ°ã«ã¯æ¤è¨¼ãè¡ã対å¿é¢æ°ãããã¾ããã
=item is_integer(value)
I<value>ãæ´æ°ãã©ããããã§ãã¯ãã¾ããããã¯C<is_number()>ã®å¤å®ã«å ãã¦ï¼
æ´æ°å¤ãã©ããããã§ãã¯ãã¾ãã
t/10_neat.t view on Meta::CPAN
is neat(*ok), '*main::ok';
ok neat({'!foo' => '!bar'});
unlike neat({foo => 'bar', baz => 'bax'}), qr/undef/;
like neat(\&foo), qr/^\\&main::foo\(.*\)$/;
like neat(Foo->new(42)), qr/^Foo=HASH\(.+\)$/, 'for an overloaded object';
like neat(qr/foo/), qr/foo/, 'neat(qr/foo/) includes "foo"';
ok neat(+9**9**9), '+Inf';
ok neat(-9**9**9), '-Inf';
ok neat(9**9**9 - 9**9**9), 'NaN';
tie my $s, 'Tie::StdScalar', "foo";
is neat($s), q{"foo"}, 'for magical scalar';
my $x;
$x = tie my @a, 'Tie::StdArray';
$x->[0] = 42;
is neat($a[0]), 42, 'for magical scalar (aelem)';
t/18_is_value.t view on Meta::CPAN
ok is_integer($x), sprintf 'is_integer(%s)', neat($x);
my $w;
local $SIG{__WARN__} = sub{ $w = "@_" };
my $i = 0+$x;
is $w, undef, 'numify-safe';
}
tie $s, 'Tie::StdScalar', 'magic';
foreach my $x(
undef, 3.14, '0.0', 'foo', (9**9**9), -(9**9**9), 'NaN',
INF(), -INF(), NAN(), -NAN(), 1 != 1,
*ok, [42], *STDIN{IO}, '0 but true', $s){
ok !is_integer($x), sprintf '!is_integer(%s)', neat($x);
}
tie $s, 'Tie::StdScalar', 123.456;
foreach my $x(0, 1, -1, 3.14, '0', '+0', '-0', '0E0', ' 0.0', '1e-1', 2**32+0.1, $s){
ok is_number($x), sprintf 'is_number(%s)', neat($x);
my $w;
local $SIG{__WARN__} = sub{ $w = "@_" };
my $n = 0+$x;
is $w, undef, 'numify-safe';
}
tie $s, 'Tie::StdScalar', 'magic';
foreach my $x(undef, 'foo', 'Inf', '-Infinity', 'NaN',
INF(), -INF(), NAN(), -NAN(), 1 != 1,
'0 but true', *ok, [42], *STDIN{IO}, $s){
ok !is_number($x), sprintf '!is_number(%s)', neat($x);
}
xs-src/misc_scalar.c view on Meta::CPAN
else{
NV const nv = SvNV(x);
if(nv == NV_INF){
sv_catpvs(dsv, "+Inf");
}
else if(nv == -NV_INF){
sv_catpvs(dsv, "-Inf");
}
else if(Perl_isnan(nv)){
sv_catpvs(dsv, "NaN");
}
else{
Perl_sv_catpvf(aTHX_ dsv, "%"NVgf, nv);
}
}
}
else{
sv_catpvs(dsv, "undef");
}
}
( run in 0.741 second using v1.01-cache-2.11-cpan-4d50c553e7e )