Func-Util
view release on metacpan or search on metacpan
include/ppport.h view on Meta::CPAN
s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
s++; if (s < send && (*s == 'I' || *s == 'i')) {
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
s++;
}
sawinf = 1;
} else if (*s == 'N' || *s == 'n') {
/* XXX TODO: There are signaling NaNs and quiet NaNs. */
s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++;
sawnan = 1;
} else
return 0;
if (sawinf) {
numtype &= IS_NUMBER_NEG; /* Keep track of sign */
numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
t/003-util-predicates-valid.t view on Meta::CPAN
subtest 'is_num edge cases' => sub {
# String that looks like number
ok(is_num('42'), 'is_num: string 42');
ok(is_num('3.14'), 'is_num: string 3.14');
ok(is_num('-5'), 'is_num: string -5');
ok(is_num('1e10'), 'is_num: string scientific');
# Special values (Perl's looks_like_number considers these numeric)
ok(is_num(0.0), 'is_num: 0.0');
ok(is_num('NaN'), 'is_num: string NaN (Perl considers numeric)');
ok(is_num('inf'), 'is_num: string inf (Perl considers numeric)');
# Whitespace (Perl's looks_like_number accepts leading/trailing spaces)
ok(is_num(' 42 '), 'is_num: number with spaces (Perl accepts)');
ok(!is_num('42abc'), 'is_num: number with trailing text');
};
# ============================================
# is_int
# ============================================
( run in 1.181 second using v1.01-cache-2.11-cpan-39bf76dae61 )