From: Tara L Andrews Date: Fri, 7 Jun 2013 10:34:40 +0000 (+0200) Subject: return the new reading generated on duplication X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ef73c20abac8480b7aec523174a167d63e51eb73;p=scpubgit%2Fstemmatology.git return the new reading generated on duplication --- diff --git a/base/lib/Text/Tradition/Collation.pm b/base/lib/Text/Tradition/Collation.pm index fcfec83..f1c9227 100644 --- a/base/lib/Text/Tradition/Collation.pm +++ b/base/lib/Text/Tradition/Collation.pm @@ -456,7 +456,9 @@ sub _objectify_args { =head2 duplicate_reading( $reading, @witlist ) Split the given reading into two, so that the new reading is in the path for -the witnesses given in @witlist. +the witnesses given in @witlist. If the result is that certain non-colocated +relationships (e.g. transpositions) are no longer valid, these will be removed. +Returns the newly-created reading. =begin testing @@ -473,7 +475,8 @@ is( scalar( $sc->readings ), $numr, "There are $numr readings in the graph" ); is( $sc->end->rank, 14, "There are fourteen ranks in the graph" ); # Detach the erroneously collated reading -$sc->duplicate_reading( 'n131', 'Ba96' ); +my $newr = $sc->duplicate_reading( 'n131', 'Ba96' ); +ok( $newr, "New reading was created" ); ok( $sc->reading('n131_0'), "Detached the bad collation with a new reading" ); is( scalar( $sc->readings ), $numr + 1, "A reading was added to the graph" ); is( $sc->end->rank, 10, "There are now only ten ranks in the graph" ); @@ -570,7 +573,8 @@ sub duplicate_reading { $self->relations->verify_or_delete( $rdg, $nc ); } } - } + } + return $newr; } sub _generate_dup_id { diff --git a/base/t/text_tradition_collation.t b/base/t/text_tradition_collation.t index ec281e5..a53965f 100644 --- a/base/t/text_tradition_collation.t +++ b/base/t/text_tradition_collation.t @@ -65,7 +65,8 @@ is( scalar( $sc->readings ), $numr, "There are $numr readings in the graph" ); is( $sc->end->rank, 14, "There are fourteen ranks in the graph" ); # Detach the erroneously collated reading -$sc->duplicate_reading( 'n131', 'Ba96' ); +my $newr = $sc->duplicate_reading( 'n131', 'Ba96' ); +ok( $newr, "New reading was created" ); ok( $sc->reading('n131_0'), "Detached the bad collation with a new reading" ); is( scalar( $sc->readings ), $numr + 1, "A reading was added to the graph" ); is( $sc->end->rank, 10, "There are now only ten ranks in the graph" );