|
sub new {
my ( $class , $value ) = @_ ;
return bless \ $value ;
}
sub __cmp__ {
my ( $self , $other ) = @_ ;
return $$self cmp $$other ;
}
sub __eq__ {
my ( $self , $other ) = @_ ;
return $$self cmp $$other ;
}
sub new {
my ( $class , $value ) = @_ ;
return bless \ $value ;
}
sub __cmp__ {
my ( $self , $other ) = @_ ;
return 'foo' ;
}
sub __eq__ {
my ( $self , $other ) = @_ ;
return 'foo' ;
}
use Inline Config => DIRECTORY => './blib_test' ; BEGIN { plan tests => 7 }
py_eval( <<'END');
def test(foo1, foo2, bar):
perl.ok(foo1 == foo1);
perl.ok(foo2 == foo2);
perl.ok(bar == bar);
perl.ok(foo1 == foo2, 'foo1 == foo2');
perl.ok(foo1 != bar);
perl.ok(foo2 != bar);
def test_fail(o1, o2):
o1 == o2
END
py_call_function( "__main__" , "test" , map { Comparer->new( $_ ) } qw(foo foo bar) );
eval {
py_call_function( "__main__" , "test_fail" , map { FailComparer->new( $_ ) } qw(foo foo) );
};
like($@, qr/__ must return an integer!/ );
|