#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Test::More ( tests => 3, # Be gentle because Test::More::is # will conflict with our &is import => [ 'use_ok', 'is_deeply', 'diag', 'can_ok', 'isa_ok', 'ok' ] ); BEGIN { use_ok('Moose::Declare'); } { my @objects = moose { class Point => authority is 'cpan://JRANDOM', version is '0.0.1'; has x => is rw, isa Int, default is 0; has y => is rw, isa Int, default is 0; class Point3D => authority is 'cpan://JRANDOM', version is '0.0.1', superclasses is [ 'Point' ]; has z => is readonly, isa Int, default is 0; }; diag(Dumper(\@objects)); can_ok('Point', 'new'); { my $p = Point->new; isa_ok($p, 'Point'); isa_ok($p, 'Moose::Object'); can_ok('Point', 'meta'); isa_ok(Point->meta, 'Class::MOP::Class'); Test::More::is(Point->meta->version, '0.0.1', '... got the right version number'); } can_ok('Point3D', 'new'); { my $p = Point3D->new; isa_ok($p, 'Point3D'); isa_ok($p, 'Point'); isa_ok($p, 'Moose::Object'); } } exit; =pod { my $default_thunk = sub { BinaryTree->new(parent => $_[0]) }; my @objects = moose { class BinaryTree => authority is 'cpan://MOOSE', version is '0.01', is rw; has node => isa Any; has parent => isa BinaryTree, is weakref, predicate is 'has_parent'; has left => isa BinaryTree, is lazy, predicate is 'has_left', default is $default_thunk; has right => isa BinaryTree, is lazy, predicate is 'has_left', default is $default_thunk; }; #diag(Dumper(\@objects)); is_deeply( \@objects, [ 'BinaryTree', [ 'class', [ 'authority', 'cpan://MOOSE', 'version', '0.01', 'rw', 1 ] ], 'node', [ 'attr', [ 'Any', 1 ] ], 'parent', [ 'attr', [ 'BinaryTree', 1, 'weakref', 1, 'predicate', 'has_parent' ] ], 'left', [ 'attr', [ 'BinaryTree', 1, 'lazy', 1, 'predicate', 'has_left', 'default', $default_thunk ] ], 'right', [ 'attr', [ 'BinaryTree', 1, 'lazy', 1, 'predicate', 'has_left', 'default', $default_thunk ] ] ], '... got the right structure'); }