lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [5/6] git commit: refs/heads/move-dumpable - Update test for `nullable` to avoid Dump().
Date Wed, 31 Jul 2013 01:11:17 GMT
Update test for `nullable` to avoid Dump().

Change the test for the behavior of Perl wrappers around `nullable`
return values to use Inc_RefCount() instead of Dump().


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/939a52f9
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/939a52f9
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/939a52f9

Branch: refs/heads/move-dumpable
Commit: 939a52f9db1189e4cbc3cc0f89c30ae2c2c94f05
Parents: 2b10863
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Jul 30 09:22:20 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Jul 30 17:57:24 2013 -0700

----------------------------------------------------------------------
 clownfish/runtime/perl/t/binding/019-obj.t | 19 ++++++++++++++-----
 perl/t/binding/019-obj.t                   | 20 +++++++++++++++-----
 2 files changed, 29 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/939a52f9/clownfish/runtime/perl/t/binding/019-obj.t
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/t/binding/019-obj.t b/clownfish/runtime/perl/t/binding/019-obj.t
index 445d70b..1088035 100644
--- a/clownfish/runtime/perl/t/binding/019-obj.t
+++ b/clownfish/runtime/perl/t/binding/019-obj.t
@@ -32,10 +32,14 @@ use base qw( TestObj );
     }
 }
 
-package BadDump;
+package BadRefCount;
 use base qw( Clownfish::Obj );
 {
-    sub dump { }
+    sub inc_refcount {
+        my $self = shift;
+        $self->SUPER::inc_refcount;
+        return;
+    }
 }
 
 package main;
@@ -79,9 +83,14 @@ like( $object->to_string, qr/STRING:.*?SonOfTestObj/,
 SKIP: {
     skip( "Exception thrown within callback leaks", 1 )
         if $ENV{LUCY_VALGRIND};
-    $hash = Clownfish::Hash->new;
-    $hash->store( foo => BadDump->new );
-    eval { $hash->dump };
+
+    # 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( capacity => 3 );
+    eval { $array->store( 1, BadRefCount->new ); };
     like( $@, qr/NULL/,
         "Don't allow methods without nullable return values to return NULL" );
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/939a52f9/perl/t/binding/019-obj.t
----------------------------------------------------------------------
diff --git a/perl/t/binding/019-obj.t b/perl/t/binding/019-obj.t
index 5d9247b..c5f3b01 100644
--- a/perl/t/binding/019-obj.t
+++ b/perl/t/binding/019-obj.t
@@ -51,10 +51,14 @@ use base qw( Lucy::Search::Query );
     sub serialize { }
 }
 
-package BadDump;
+package BadRefCount;
 use base qw( Clownfish::Obj );
 {
-    sub dump { }
+    sub inc_refcount {
+        my $self = shift;
+        $self->SUPER::inc_refcount;
+        return;
+    }
 }
 
 package LegacyObj;
@@ -120,9 +124,15 @@ SKIP: {
 SKIP: {
     skip( "Exception thrown within callback leaks", 1 )
         if $ENV{LUCY_VALGRIND};
-    $hash = Clownfish::Hash->new;
-    $hash->store( foo => BadDump->new );
-    eval { $hash->dump };
+
+    # 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( capacity => 3 );
+    eval { $array->store( 1, BadRefCount->new ); };
     like( $@, qr/NULL/,
         "Don't allow methods without nullable return values to return NULL" );
 }
+


Mime
View raw message