Commits

Anonymous committed 3507488

Add tests for mindex and maxdex under S::D::Full.

Comments (0)

Files changed (1)

Statistics-Descriptive/t/descr.t

 use strict;
 use warnings;
 
-use Test::More tests => 55;
+use Test::More tests => 59;
 
 use lib 't/lib';
 use Utils qw/is_between compare_hash_by_ranges/;
 
 }
 
+#  Tests for mindex and maxdex on unsorted data,
+#  including when new data are added which should not change the values
+{
+    my $stats_class = 'Statistics::Descriptive::Full';
+    my $stat1 = $stats_class->new();
+
+    my @data1 = (20, 1 .. 3, 100, 1..5);
+    my @data2 = (25, 30);
+
+    my $e_maxdex = 4;
+    my $e_mindex = 1;
+
+    $stat1->add_data(@data1);     # initialise
+    
+    # TEST*2
+    is ($stat1->mindex, $e_mindex, "initial mindex is correct");
+    is ($stat1->maxdex, $e_maxdex, "initial maxdex is correct");
+
+    # TEST*2
+    $stat1->add_data(@data2);     #  add new data
+    is ($stat1->mindex, $e_mindex, "mindex is correct after new data added");
+    is ($stat1->maxdex, $e_maxdex, "maxdex is correct after new data added");
+}
+
+
 #  what happens when we add new data?
 #  Recycle the same data so mean, sd etc remain the same
 {
         $stat2->$meth;
     }
 
-    #TEST
+    # TEST
     is_deeply (
         $stat1,
         $stat2,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.