Fix some test-only memory leaks.

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

Branch: refs/heads/master
Commit: b8cfae56415acd084f299b42c21988c96ef2be7d
Parents: 4e8f130
Author: Marvin Humphrey <[email protected]>
Authored: Wed Jul 23 15:39:48 2014 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Sun Jul 27 02:05:38 2014 +0100

----------------------------------------------------------------------
 runtime/core/Clownfish/Test/TestCharBuf.c |  2 +-
 runtime/core/Clownfish/Test/TestString.c  |  5 +----
 runtime/core/Clownfish/Test/TestVArray.c  |  6 +++---
 runtime/perl/t/binding/019-obj.t          | 12 ++++++++----
 4 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b8cfae56/runtime/core/Clownfish/Test/TestCharBuf.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestCharBuf.c 
b/runtime/core/Clownfish/Test/TestCharBuf.c
index d6d4d50..39cb09c 100644
--- a/runtime/core/Clownfish/Test/TestCharBuf.c
+++ b/runtime/core/Clownfish/Test/TestCharBuf.c
@@ -110,6 +110,7 @@ test_Mimic_and_Clone(TestBatchRunner *runner) {
     DECREF(got);
 
     DECREF(wanted);
+    DECREF(wanted_cb);
 }
 
 /*
@@ -296,4 +297,3 @@ TestCB_Run_IMP(TestCharBuf *self, TestBatchRunner *runner) {
     test_Mimic_and_Clone(runner);
 }
 
-

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b8cfae56/runtime/core/Clownfish/Test/TestString.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestString.c 
b/runtime/core/Clownfish/Test/TestString.c
index 4e506ff..7eff793 100644
--- a/runtime/core/Clownfish/Test/TestString.c
+++ b/runtime/core/Clownfish/Test/TestString.c
@@ -99,12 +99,9 @@ test_Cat(TestBatchRunner *runner) {
 static void
 test_Clone(TestBatchRunner *runner) {
     String *wanted = S_get_str("foo");
-    String *got    = S_get_str("bar");
-
-    got = Str_Clone(wanted);
+    String *got    = Str_Clone(wanted);
     TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Clone");
     DECREF(got);
-
     DECREF(wanted);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b8cfae56/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestVArray.c 
b/runtime/core/Clownfish/Test/TestVArray.c
index 3975090..f817944 100644
--- a/runtime/core/Clownfish/Test/TestVArray.c
+++ b/runtime/core/Clownfish/Test/TestVArray.c
@@ -64,9 +64,9 @@ test_Equals(TestBatchRunner *runner) {
     TEST_FALSE(runner, VA_Equals(array, (Obj*)other),
                "Non-matching value spoils Equals");
 
-    VA_Excise(array, 1, 2); // removes empty elems
-    VA_Delete(other, 1);    // leaves NULL in place of deleted elem
-    VA_Delete(other, 2);
+    VA_Excise(array, 1, 2);       // removes empty elems
+    DECREF(VA_Delete(other, 1));  // leaves NULL in place of deleted elem
+    DECREF(VA_Delete(other, 2));
     TEST_FALSE(runner, VA_Equals(array, (Obj*)other),
                "Empty trailing elements spoil Equals");
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b8cfae56/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 0c2734f..347ea65 100644
--- a/runtime/perl/t/binding/019-obj.t
+++ b/runtime/perl/t/binding/019-obj.t
@@ -61,10 +61,14 @@ my $object = TestObj->new;
 isa_ok( $object, "Clownfish::Obj",
     "Clownfish objects can be subclassed" );
 
-my $thawed = TestObj->new;
-eval { freeze($thawed) };
-like( $@, qr/implement/i,
-    "freezing an Obj throws an exception rather than segfaults" );
+SKIP: {
+    skip( "Exception thrown within STORABLE hook leaks", 1 )
+        if $ENV{LUCY_VALGRIND};
+    my $thawed = TestObj->new;
+    eval { freeze($thawed) };
+    like( $@, qr/implement/i,
+        "freezing an Obj throws an exception rather than segfaults" );
+}
 
 my $fake = bless {}, 'ThawTestObj';
 my $frozen = freeze($fake);

Reply via email to