new operator overload tests to locate bugs in pre- increment/decrement operators

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10338 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Jason Stewart 2008-04-03 11:48:41 +00:00
commit ad93f971ca
3 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,38 @@
#!/usr/bin/perl -w
use strict;
use Test::More tests => 6;
use operator_overload_break;
# Workaround for
# ok( not (expression) , "test description" );
# does not working in older versions of Perl, eg 5.004_04
sub ok_not ($;$) {
my($test, $name) = @_;
$test = not $test;
ok($test, $name);
}
pass("loaded");
my $op = operator_overload_break::Op->new(5);
isa_ok($op, "operator_overload_break::Op");
ok((2 == $op - 3),
"subtraction");
$op->{k} = 37;
ok((40 == $op + 3),
"addition");
($op + 3)->Print();
$op->{k} = 22;
ok((10 == (32 - $op)),
"reversed subtraction");
ok_not((3 == $op),
'not equal');