You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2015/02/13 22:45:55 UTC
[05/16] lucy-clownfish git commit: Use different method in nullable
binding test.
Use different method in nullable binding test.
Instead of calling `Inc_RefCount` from C-space, call `To_String`.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/a1155b37
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/a1155b37
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/a1155b37
Branch: refs/heads/master
Commit: a1155b3707b93631397b383adf9d58f7caf00c9f
Parents: cd6c304
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sat Feb 7 09:44:36 2015 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sat Feb 7 09:44:36 2015 -0800
----------------------------------------------------------------------
.../perl/buildlib/Clownfish/Build/Binding.pm | 8 +++++++
runtime/perl/t/binding/019-obj.t | 22 ++++++++------------
2 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a1155b37/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index 98c7f0d..049945c 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -102,6 +102,14 @@ CODE:
RETVAL = result;
OUTPUT: RETVAL
+
+void
+invoke_to_string(sv)
+ SV *sv;
+PPCODE:
+ cfish_Obj *obj = XSBind_sv_to_cfish_obj(sv, CFISH_OBJ, NULL);
+ cfish_String *str = CFISH_Obj_To_String(obj);
+ CFISH_DECREF(str);
END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a1155b37/runtime/perl/t/binding/019-obj.t
----------------------------------------------------------------------
diff --git a/runtime/perl/t/binding/019-obj.t b/runtime/perl/t/binding/019-obj.t
index 06e3642..83134d9 100644
--- a/runtime/perl/t/binding/019-obj.t
+++ b/runtime/perl/t/binding/019-obj.t
@@ -32,14 +32,10 @@ use base qw( TestObj );
}
}
-package BadRefCount;
+package BadToString;
use base qw( Clownfish::Obj );
{
- sub inc_refcount {
- my $self = shift;
- $self->SUPER::inc_refcount;
- return;
- }
+ sub to_string {}
}
package ThawTestObj;
@@ -63,6 +59,7 @@ use base qw( Clownfish::Test::AliasTestObj );
package main;
use Storable qw( freeze thaw );
+use Clownfish::Test;
ok( defined $TestObj::version,
"Using base class should grant access to "
@@ -123,13 +120,12 @@ SKIP: {
skip( "Exception thrown within callback leaks", 2 )
if $ENV{LUCY_VALGRIND};
- # The Perl binding for VArray#store calls inc_refcount() from C space.
- # This test verifies that the Perl bindings generated by CFC handle
- # non-`nullable` return values correctly, by ensuring that the Perl
- # callback wrapper for inc_refcount() checks the return value and throws
- # an exception if a Perl-space implementation returns undef.
- my $array = Clownfish::VArray->new;
- eval { $array->store( 1, BadRefCount->new ); };
+ # Invoke To_String() from C space. This test verifies that the Perl
+ # bindings generated by CFC handle non-`nullable` return values correctly,
+ # by ensuring that the Perl callback wrapper for to_string() checks the
+ # return value and throws an exception if a Perl-space implementation
+ # returns undef.
+ eval { Clownfish::Test::invoke_to_string( BadToString->new ) };
like( $@, qr/NULL/,
"Don't allow methods without nullable return values to return NULL" );