| 1 | 1 | ▶ | use Test::More; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | |||
| 3 | # this tests make sure that safe_clone actually increments the ids for the | ||
| 4 | # objects in the new (cloned) molecule | ||
| 5 | |||
| 6 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | #plan 'no_plan'; | ||
| 10 | 1 | plan tests => 9; | |
| 11 | |||
| 12 | 1 | ▶ | use Chemistry::File::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 1 | my $mol = Chemistry::Mol->new; | |
| 15 | 1 | $mol->new_atom(symbol => 'C'); | |
| 16 | 1 | $mol->new_atom(symbol => 'C'); | |
| 17 | 1 | $mol->new_bond(atoms => [$mol->atoms(1,2)]); | |
| 18 | |||
| 19 | 1 | is( $mol->atoms(1)->id, 'a1', 'atom(1) before clone'); | |
| 20 | 1 | is( $mol->bonds(1)->id, 'b1', 'bond(1) before clone'); | |
| 21 | 1 | is( $mol->id, 'mol1', 'mol->id before clone'); | |
| 22 | |||
| 23 | 1 | my $mol2 = $mol->clone; | |
| 24 | 1 | is( $mol2->atoms(1)->id, 'a1', 'atom(1) after clone'); | |
| 25 | 1 | is( $mol2->bonds(1)->id, 'b1', 'bond(1) after clone'); | |
| 26 | 1 | is( $mol2->id, 'mol1', 'mol->id after clone'); | |
| 27 | |||
| 28 | 1 | $mol2 = $mol->safe_clone; | |
| 29 | 1 | is( $mol2->atoms(1)->id, 'a3', 'atom(1) after safe_clone'); | |
| 30 | 1 | is( $mol2->bonds(1)->id, 'b2', 'bond(1) after safe_clone'); | |
| 31 | 1 | is( $mol2->id, 'mol2', 'mol->id after safe clone'); | |
| 32 | |||