mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 08:38:23 +00:00
add tests for void context calls to overloads
Discovered while working on another module, in many amagic_call() will use the current context when calling the overload sub, but these APIs might be called in XS code that simply needs a comparison, regardless of the current OP context.
This commit is contained in:
parent
2c33801f68
commit
9edfa4656a
@ -5058,6 +5058,14 @@ sv_numeq_flags(nullable_SV sv1, nullable_SV sv2, U32 flags)
|
||||
bool
|
||||
sv_numne(nullable_SV sv1, nullable_SV sv2)
|
||||
|
||||
# deliberately void context
|
||||
void
|
||||
void_sv_numne(nullable_SV sv1, nullable_SV sv2, SV *out)
|
||||
CODE:
|
||||
sv_setbool(out, sv_numne(sv1, sv2));
|
||||
OUTPUT:
|
||||
out
|
||||
|
||||
bool
|
||||
sv_numne_flags(nullable_SV sv1, nullable_SV sv2, U32 flags)
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!perl
|
||||
|
||||
use Test::More tests => 22;
|
||||
use Test::More tests => 24;
|
||||
use XS::APItest;
|
||||
use Config;
|
||||
|
||||
@ -44,7 +44,13 @@ ok !sv_numne_flags($1, 11, SV_GMAGIC), 'sv_numne_flags with SV_GMAGIC does';
|
||||
ok !sv_numne(12, $obj), 'AlwaysTwelve is 12 on right';
|
||||
ok sv_numne(11, $obj), 'AlwayeTwelve is not 11 on the right';
|
||||
|
||||
ok !sv_numne_flags($obj, 11, SV_SKIP_OVERLOAD), 'AlwaysTwelve is 12 with SV_SKIP_OVERLOAD'
|
||||
ok !sv_numne_flags($obj, 11, SV_SKIP_OVERLOAD), 'AlwaysTwelve is 12 with SV_SKIP_OVERLOAD';
|
||||
|
||||
my $result;
|
||||
void_sv_numne($obj, 11, $result);
|
||||
ok($result, "overloaded sv_numne() (ne) in void context");
|
||||
void_sv_numne($obj, 12, $result);
|
||||
ok(!$result, "overloaded sv_numne() (eq) in void context");
|
||||
}
|
||||
|
||||
# +0 overloading with large numbers and using fallback
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user