SvGETMAGIC(TOPs);
if (((SvIOKp(TOPs) && !SvIsUV(TOPs) && SvIV_nomg(TOPs) < 0)
||
- (SvNOKp(TOPs) && SvNV_nomg(TOPs) < 0.0))) {
+ ((SvNOKp(TOPs) || (SvOK(TOPs) && !SvIsUV(TOPs)))
+ && SvNV_nomg(TOPs) < 0.0))) {
if (IN_BYTES) {
value = SvUV_nomg(TOPs); /* chr(-1) eq chr(0xff), etc. */
(void)POPs;
require "test.pl";
}
-plan tests => 38;
+plan tests => 42;
# Note that t/op/ord.t already tests for chr() <-> ord() rountripping.
is(chr(-2 ), "\xFE");
is(chr(-3.0), "\xFD");
}
+
# Make sure -1 is treated the same way when coming from a tied variable
sub TIESCALAR {bless[]}
sub STORE { $_[0][0] = $_[1] }
$t = -1.1; is chr $t, chr -1.1, 'chr $tied when $tied is -1.1';
$t = -2.2; is chr $t, chr -2.2, 'chr $tied when $tied is -2.2';
+# And that stringy scalars are treated likewise
+is chr "-1", chr -1, 'chr "-1" eq chr -1';
+is chr "-2", chr -2, 'chr "-2" eq chr -2';
+is chr "-1.1", chr -1.1, 'chr "-1.1" eq chr -1.1';
+is chr "-2.2", chr -2.2, 'chr "-2.2" eq chr -2.2';
+
# Check UTF-8 (not UTF-EBCDIC).
SKIP: {
skip "no UTF-8 on EBCDIC", 21 if chr(193) eq 'A';