Subject: | patch: add test for effect of adding new data |
Hello Shlomi,
While poking around with Stats::Descriptive::Full::add_data I noticed
that the test suite does not contain explicit tests for the effect of
adding new data. The attached patch does this.
I was poking around to see if I could speed up the add_data sub. I'll
submit a separate RT for that, though.
Regards,
Shawn.
Subject: | patch_test_add_data.diff |
diff -r a0205d94916c Statistics-Descriptive/t/descr.t
--- a/Statistics-Descriptive/t/descr.t Tue May 15 19:44:26 2012 +0300
+++ b/Statistics-Descriptive/t/descr.t Sat Mar 02 19:14:24 2013 +1100
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 54;
+use Test::More tests => 55;
use lib 't/lib';
use Utils qw/is_between compare_hash_by_ranges/;
@@ -452,3 +452,38 @@
);
}
+
+
+# what happens when we add new data?
+{
+ my $stat1 = Statistics::Descriptive::Full->new();
+ my $stat2 = Statistics::Descriptive::Full->new();
+
+ my @data1 = (1 .. 9, 100);
+ my @data2 = (100 .. 110);
+
+ # sample of methods
+ my @methods = qw /mean standard_deviation count skewness kurtosis median/;
+
+ $stat1->add_data(@data1); # initialise
+ foreach my $meth (@methods) { # run some methods
+ $stat1->$meth;
+ }
+ $stat1->add_data(@data2); # add new data
+ foreach my $meth (@methods) { # re-run some methods
+ $stat1->$meth;
+ }
+
+ $stat2->add_data(@data1, @data2); # initialise with all data
+ foreach my $meth (@methods) { # run some methods
+ $stat2->$meth;
+ }
+
+ #TEST
+ is_deeply (
+ $stat1,
+ $stat2,
+ 'stats consistent after adding new data',
+ );
+
+}