Add missing file from change #30454
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 3 Mar 2007 18:19:01 +0000 (18:19 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 3 Mar 2007 18:19:01 +0000 (18:19 +0000)
p4raw-link: @30454 on //depot/perl: caa6400115a38c0669db5e1b28eaa0eb8d1aad26

p4raw-id: //depot/perl@30455

ext/Math/BigInt/FastCalc/t/leak.t [new file with mode: 0644]

diff --git a/ext/Math/BigInt/FastCalc/t/leak.t b/ext/Math/BigInt/FastCalc/t/leak.t
new file mode 100644 (file)
index 0000000..c7cae8b
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w
+
+# Test for memory leaks from _zero() and friends.
+
+use Test::More;
+use strict;
+
+BEGIN
+  {
+  $| = 1;
+  chdir 't' if -d 't';
+  unshift @INC, ('../lib', '../blib/arch');    # for running manually
+  plan tests => 4;
+  }
+
+#############################################################################
+package Math::BigInt::FastCalc::LeakCheck;
+use base qw(Math::BigInt::FastCalc);
+
+my $destroyed = 0;
+sub DESTROY { $destroyed++ }
+
+#############################################################################
+package main;
+
+for my $method (qw(_zero _one _two _ten))
+  {
+  $destroyed = 0;
+    {
+    my $num = Math::BigInt::FastCalc::LeakCheck->$method();
+    bless $num, "Math::BigInt::FastCalc::LeakCheck";
+    }
+  is ($destroyed, 1, "$method does not leak memory");
+  }