Permalink
Browse files

adding calc_new_deltas.t, cleanup in other test's comments

  • Loading branch information...
1 parent bbe09f7 commit 938b80dc12e3a5bd29fa8a11b297d5118417f7ff @Tlousky committed Jun 16, 2010
Showing with 58 additions and 10 deletions.
  1. +47 −0 t/calc_new_deltas.t
  2. +3 −3 t/calc_new_endpoints.t
  3. +5 −4 t/calc_new_nodulation.t
  4. +3 −3 t/create_path.t
View
@@ -0,0 +1,47 @@
+#!perl
+
+# Checking the function Algorithm::Shape::RandomTree::calc_new_deltas
+
+use strict;
+use warnings;
+
+use Test::More tests => 15;
+use Test::Exception;
+
+use Algorithm::Shape::RandomTree;
+use Algorithm::Shape::RandomTree::Branch;
+
+## calc_new_nodulation accepts: ( $parent )
+## and requires the RandomTree attributes: dx_range, dy_range
+## and the RandomTree::Branch attributes: level, dx, dy
+
+my $tester = Algorithm::Shape::RandomTree->new(
+ dx_range => 2,
+ dy_range => 2,
+);
+
+my $parent = Algorithm::Shape::RandomTree::Branch->new(
+ dx => 2,
+ dy => 2,
+ level => 4,
+);
+
+## Test 1: getting parameters from objects
+
+# t1:
+ok( defined $tester->dx_range, "got a value in the Tree's dx_range attribute" );
+
+# t2:
+ok( defined $tester->dy_range, "got a value in the Tree's dy_range attribute" );
+
+# t3:
+ok( defined $parent->dx, "got a value in the Parent's dx attribute" );
+
+# t4:
+ok( defined $parent->dy, "got a value in the Parent's dy attribute" );
+
+# t5:
+ok( defined $parent->level, "got a value in the Parent's level attribute" );
+
+
+## Test 2: succeed in
View
@@ -15,7 +15,7 @@ use Algorithm::Shape::RandomTree::Branch::Point;
my $tester = Algorithm::Shape::RandomTree->new();
-## Test 1: succeed in calculating new endpoint with correct params
+## Test 1: Calculating new endpoint with correct params
my $startp = Algorithm::Shape::RandomTree::Branch::Point->new(
x => 1,
@@ -35,7 +35,7 @@ is( $retur_x_end, $x_end, 'Calculated correct endpoint.x value' );
# t2:
is( $retur_y_end, $y_end, 'Calculated correct endpoint.y value' );
-## Test 2: wrong type of start point or undef value
+## Test 2: Wrong type of start point or undef value
$startp = 1;
@@ -51,7 +51,7 @@ throws_ok { $tester->calc_new_endpoints( $startp, $dx, $dy ) }
qr{^Error in use of 'calc_new_endpoints'. The wrong parameter is: start point},
'calc_new_enpoints dies with a relevant msg when given undef as a start point';
-## Test 3: wrong or undef dx and dy values
+## Test 3: Wrong or undef dx and dy values
$startp = Algorithm::Shape::RandomTree::Branch::Point->new(
x => 1,
View
@@ -12,7 +12,8 @@ use Algorithm::Shape::RandomTree;
use Algorithm::Shape::RandomTree::Branch;
## calc_new_nodulation accepts: ( $parent )
-## and requires the RandomTree attributes: nodulation, ebbing_factor
+## and requires the RandomTree attribute: ebbing_factor
+## and the RandomTree::Branch attribute: nodulation
my $tester = Algorithm::Shape::RandomTree->new(
ebbing_factor => 2,
@@ -22,7 +23,7 @@ my $test_branch = Algorithm::Shape::RandomTree::Branch->new(
nodulation => 10,
);
-## Test 1: succeed getting parameters from objects
+## Test 1: Getting parameters from objects
# t1:
ok( defined $tester->ebbing_factor, "got a value in the Tree's ebbing_factor attribute" );
@@ -31,7 +32,7 @@ ok( defined $tester->ebbing_factor, "got a value in the Tree's ebbing_factor att
ok( defined $test_branch->nodulation, "got a value in the Branch's nodulation attribute" );
-## Test 2: succeed calculating a new nodulation value with correct params
+## Test 2: Calculating a new nodulation value with correct params
my $result = $tester->calc_new_nodulation( $test_branch );
my $correct_new_nodulation = $test_branch->nodulation - $tester->ebbing_factor;
@@ -42,7 +43,7 @@ ok( defined $result, 'got back a new nodulation value' );
# t4:
is( $result, $correct_new_nodulation, 'correct calculation of new nodulation value' );
-## Test 3: wrong type of parent
+## Test 3: Wrong type of parent
$test_branch = 1;
View
@@ -42,7 +42,7 @@ my $phandle = $tester->branch_curve * sqrt( $dx ** 2 + $dy ** 2 );
# Check path string thoroughly, all params included. Total of 11 test:
my $result = check_path_string( $path_str, $startp->x, $startp->y, $endp->x, $endp->y, $phandle );
-## Test 3: scalars instead of Point objects:
+## Test 3: Scalars instead of Point objects:
$startp = 1;
# t13:
@@ -62,7 +62,7 @@ throws_ok { $tester->create_path( $startp, $endp, $dx, $dy ) }
qr{^Error in use of 'create_path'. The wrong parameter is: end point},
'create_path dies with a relevant msg when given a wrong type of end point';
-## Test 4: strings instead of numbers in dx and dy
+## Test 4: Strings instead of numbers in dx and dy
$endp = Algorithm::Shape::RandomTree::Branch::Point->new(
x => 2,
@@ -85,7 +85,7 @@ throws_ok { $tester->create_path( $startp, $endp, $dx, $dy ) }
'create_path dies with a relevant msg when given a wrong type of dy value';
-## Test 5: undefined parameters
+## Test 5: Undefined parameters
$dy = 2;
$startp = undef;

0 comments on commit 938b80d

Please sign in to comment.