add __not__ and test the new bool typemaps
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8349 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
06a949da6d
commit
38c8cf2cb8
2 changed files with 19 additions and 6 deletions
|
|
@ -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'";
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue