Add another MOOSE_TEST_MD option, MooseX
[gitmo/Moose.git] / t / native_traits / shallow_clone.t
CommitLineData
444a29de 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use Test::Fatal;
8use Scalar::Util qw(refaddr);
9
10{
11 package Foo;
12 use Moose;
13
14 has 'array' => (
15 traits => ['Array'],
16 is => 'ro',
17 handles => { array_clone => 'shallow_clone' },
18 );
19
20 has 'hash' => (
21 traits => ['Hash'],
22 is => 'ro',
23 handles => { hash_clone => 'shallow_clone' },
24 );
25
26 no Moose;
27}
28
29my $array = [ 1, 2, 3 ];
30my $hash = { a => 1, b => 2 };
31
32my $obj = Foo->new({
33 array => $array,
34 hash => $hash,
35});
36
37my $array_clone = $obj->array_clone;
38my $hash_clone = $obj->hash_clone;
39
40isnt(refaddr($array), refaddr($array_clone), "array clone refers to new copy");
41is_deeply($array_clone, $array, "...but contents are the same");
42isnt(refaddr($hash), refaddr($hash_clone), "hash clone refers to new copy");
43is_deeply($hash_clone, $hash, "...but contents are the same");
44
45done_testing;