diff --git a/SWIG/Examples/test-suite/perl5/operator_overload_runme.pl b/SWIG/Examples/test-suite/perl5/operator_overload_runme.pl index fe6401478..bfbcd808e 100644 --- a/SWIG/Examples/test-suite/perl5/operator_overload_runme.pl +++ b/SWIG/Examples/test-suite/perl5/operator_overload_runme.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 26; +use Test::More tests => 28; use operator_overload; pass("loaded"); @@ -108,10 +108,18 @@ $op->{i} = 7; $op--; is($op->{i}, 6, "operator decrement"); -# inverse operator +# neg operator $op->{i} = 3; $op2 = -$op; -is($op2->{i}, -3, "operator inverse"); +is($op2->{i}, -3, "operator neg"); + +# not operator +$op->{i} = 0; +is(!$op, !0, "operator not"); + +$op->{i} = 1; +is(!$op, !1, "operator not"); + # TODO : { # local $TODO = "I can't get Perl to trigger overloaded 'and' and 'or'"; diff --git a/SWIG/Source/Modules/perl5.cxx b/SWIG/Source/Modules/perl5.cxx index 9cf7e59d9..4b573808f 100644 --- a/SWIG/Source/Modules/perl5.cxx +++ b/SWIG/Source/Modules/perl5.cxx @@ -1214,12 +1214,14 @@ public: } else if (strstr(name, "__mod__")) { Printv(pm, tab4, "\"%\" => sub { $_[0]->__mod__($_[1])},\n",NIL); } else if (strstr(name, "__and__")) { - Printv(pm, tab4, "\"&&\" => sub { $_[0]->__and__($_[1])},\n",NIL); + Printv(pm, tab4, "\"&\" => sub { $_[0]->__and__($_[1])},\n",NIL); } else if (strstr(name, "__or__")) { - Printv(pm, tab4, "\"||\" => sub { $_[0]->__or__($_[1])},\n",NIL); + Printv(pm, tab4, "\"|\" => sub { $_[0]->__or__($_[1])},\n",NIL); } else if (strstr(name, "__gt__")) { Printv(pm, tab4, "\">\" => sub { $_[0]->__gt__($_[1])},\n",NIL); - } else if (strstr(name, "__lt__")) { + } else if (strstr(name, "__not__")) { + Printv(pm, tab4, "\"!\" => sub { $_[0]->__not__()},\n",NIL); + }else if (strstr(name, "__lt__")) { Printv(pm, tab4, "\"<\" => sub { $_[0]->__lt__($_[1])},\n",NIL); } else if (strstr(name, "__pluseq__")) { Printv(pm, tab4, "\"+=\" => sub { $_[0]->__pluseq__($_[1])},\n",NIL); @@ -1341,6 +1343,9 @@ public: } else if (Strstr(symname, "__or__")) { DohSetInt(operators,"__or__",1); have_operators = 1; + } else if (Strstr(symname, "__not__")) { + DohSetInt(operators,"__not__",1); + have_operators = 1; } else if (Strstr(symname, "__gt__")) { DohSetInt(operators,"__gt__",1); have_operators = 1;