Skip to content

Instantly share code, notes, and snippets.

@spazm
Created October 5, 2009 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spazm/201761 to your computer and use it in GitHub Desktop.
Save spazm/201761 to your computer and use it in GitHub Desktop.
use Test::More;
#use Secret::Object;
#use Secret::Message;
BEGIN { use_ok('Secret::Object') };
BEGIN { use_ok('Secret::Message') };
my %attrs_for_object1 = ();
my %attrs_for_object2 = ();
my $obj1 = Secret::Object->new(%attrs_for_object1);
my $obj2 = Secret::Object->new(%attrs_for_object2);
isnt( $obj1->id, $obj2->id, "id is distinct" );
my $message = $obj1->make_message('copy_my_state');
isa_ok( $message, 'Secret::Message' );
my $prior_id = $obj2->id;
my $prior_state = $obj2->get_public_state;
my $expected_state = $obj1->get_public_state;
$obj2->apply_message($message);
is( $obj2->id, $prior_id, "id did not change" );
is_deeply( $obj2->state, $expected_state,
"state of obj2 set to match state of obj1" );
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment