use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 12;
use Test::Moose;
+use MetaTest;
+
{
package MyHomePage;
use Moose;
is( $page->counter, 0, '... got the original value' );
# check the meta ..
-
-my $counter = $page->meta->get_attribute('counter');
-does_ok( $counter, 'Moose::Meta::Attribute::Native::Trait::Counter' );
-
-is( $counter->type_constraint->name, 'Num',
- '... got the expected default type constraint' );
-
-is_deeply(
- $counter->handles,
- {
- 'inc_counter' => 'inc',
- 'dec_counter' => 'dec',
- 'reset_counter' => 'reset',
- 'set_counter' => 'set',
- },
- '... got the right default handles methods'
-);
+skip_meta {
+ my $counter = $page->meta->get_attribute('counter');
+ does_ok( $counter, 'Moose::Meta::Attribute::Native::Trait::Counter' );
+
+ is( $counter->type_constraint->name, 'Num',
+ '... got the expected default type constraint' );
+
+ is_deeply(
+ $counter->handles,
+ {
+ 'inc_counter' => 'inc',
+ 'dec_counter' => 'dec',
+ 'reset_counter' => 'reset',
+ 'set_counter' => 'set',
+ },
+ '... got the right default handles methods'
+ );
+} 3;
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 11;
use Test::Exception;
+use MetaTest;
+
{
package MyHomePage;
use Moose;
reset_counter
];
-lives_ok {
- $page->meta->remove_attribute('counter');
-}
-'... removed the counter attribute okay';
+skip_meta {
+ lives_ok {
+ $page->meta->remove_attribute('counter');
+ }
+ '... removed the counter attribute okay';
-ok( !$page->meta->has_attribute('counter'),
- '... no longer has the attribute' );
+ ok( !$page->meta->has_attribute('counter'),
+ '... no longer has the attribute' );
+
+ ok( !$page->can($_), "... our class no longer has the $_ method" ) for qw[
+ counter
+ dec_counter
+ inc_counter
+ reset_counter
+ ];
+} 6;
-ok( !$page->can($_), "... our class no longer has the $_ method" ) for qw[
- counter
- dec_counter
- inc_counter
- reset_counter
-];
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 16;
use Test::Moose 'does_ok';
+use MetaTest;
+
{
package MyHomePage;
use Moose;
is( $page->counter, 2, '... decrement by arg' );
# check the meta ..
-
-my $counter = $page->meta->get_attribute('counter');
-does_ok( $counter, 'Moose::Meta::Attribute::Native::Trait::Counter' );
-
-is( $counter->type_constraint->name, 'Int',
- '... got the expected type constraint' );
-
-is_deeply(
- $counter->handles,
- {
- inc_counter => 'inc',
- dec_counter => 'dec',
- reset_counter => 'reset',
- set_counter => 'set'
- },
- '... got the right handles methods'
-);
-
+skip_meta {
+ my $counter = $page->meta->get_attribute('counter');
+ does_ok( $counter, 'Moose::Meta::Attribute::Native::Trait::Counter' );
+
+ is( $counter->type_constraint->name, 'Int',
+ '... got the expected type constraint' );
+
+ is_deeply(
+ $counter->handles,
+ {
+ inc_counter => 'inc',
+ dec_counter => 'dec',
+ reset_counter => 'reset',
+ set_counter => 'set'
+ },
+ '... got the right handles methods'
+ );
+
+} 3;
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 68;
use Test::Exception;
use Test::Moose 'does_ok';
+use MetaTest;
+
my $sort;
{
'... accessor rejects 3 args';
## test the meta
+skip_meta {
+ my $options = $stuff->meta->get_attribute('options');
+ does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Array' );
+
+ is_deeply(
+ $options->handles,
+ {
+ 'add_options' => 'push',
+ 'remove_last_option' => 'pop',
+ 'remove_first_option' => 'shift',
+ 'insert_options' => 'unshift',
+ 'get_option_at' => 'get',
+ 'set_option_at' => 'set',
+ 'num_options' => 'count',
+ 'has_no_options' => 'is_empty',
+ 'clear_options' => 'clear',
+ 'splice_options' => 'splice',
+ 'sort_options_in_place' => 'sort_in_place',
+ 'option_accessor' => 'accessor',
+ 'add_options_with_speed' => [ 'push' => 'funrolls', 'funbuns' ],
+ 'prepend_prerequisites_along_with' =>
+ [ 'unshift' => 'first', 'second' ],
+ 'descending_options' => [ 'sort_in_place' => $sort ],
+ },
+ '... got the right handles mapping'
+ );
+
+ is( $options->type_constraint->type_parameter, 'Str',
+ '... got the right container type' );
+} 3;
-my $options = $stuff->meta->get_attribute('options');
-does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Array' );
-
-is_deeply(
- $options->handles,
- {
- 'add_options' => 'push',
- 'remove_last_option' => 'pop',
- 'remove_first_option' => 'shift',
- 'insert_options' => 'unshift',
- 'get_option_at' => 'get',
- 'set_option_at' => 'set',
- 'num_options' => 'count',
- 'has_no_options' => 'is_empty',
- 'clear_options' => 'clear',
- 'splice_options' => 'splice',
- 'sort_options_in_place' => 'sort_in_place',
- 'option_accessor' => 'accessor',
- 'add_options_with_speed' => [ 'push' => 'funrolls', 'funbuns' ],
- 'prepend_prerequisites_along_with' =>
- [ 'unshift' => 'first', 'second' ],
- 'descending_options' => [ 'sort_in_place' => $sort ],
- },
- '... got the right handles mapping'
-);
-
-is( $options->type_constraint->type_parameter, 'Str',
- '... got the right container type' );
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 46;
use Test::Exception;
use Test::Moose 'does_ok';
+use MetaTest;
+
{
package Stuff;
use Moose;
'... bad constructor params';
## test the meta
-
-my $options = $stuff->meta->get_attribute('options');
-does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Hash' );
-
-is_deeply(
- $options->handles,
- {
- 'set_option' => 'set',
- 'get_option' => 'get',
- 'has_no_options' => 'empty',
- 'num_options' => 'count',
- 'clear_options' => 'clear',
- 'delete_option' => 'delete',
- 'has_option' => 'exists',
- 'is_defined' => 'defined',
- 'option_accessor' => 'accessor',
- 'key_value' => 'kv',
- 'options_elements' => 'elements',
- 'quantity' => [ accessor => 'quantity' ],
- },
- '... got the right handles mapping'
-);
-
-is( $options->type_constraint->type_parameter, 'Str',
- '... got the right container type' );
+skip_meta {
+ my $options = $stuff->meta->get_attribute('options');
+ does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Hash' );
+
+ is_deeply(
+ $options->handles,
+ {
+ 'set_option' => 'set',
+ 'get_option' => 'get',
+ 'has_no_options' => 'empty',
+ 'num_options' => 'count',
+ 'clear_options' => 'clear',
+ 'delete_option' => 'delete',
+ 'has_option' => 'exists',
+ 'is_defined' => 'defined',
+ 'option_accessor' => 'accessor',
+ 'key_value' => 'kv',
+ 'options_elements' => 'elements',
+ 'quantity' => [ accessor => 'quantity' ],
+ },
+ '... got the right handles mapping'
+ );
+
+ is( $options->type_constraint->type_parameter, 'Str',
+ '... got the right container type' );
+} 3;
$stuff->set_option( oink => "blah", xxy => "flop" );
my @key_value = $stuff->key_value;
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 25;
use Test::Moose;
+use MetaTest;
+
{
package Real;
use Moose;
is $real->integer, 12, 'dec 13';
## test the meta
-
-my $attr = $real->meta->get_attribute('integer');
-does_ok( $attr, 'Moose::Meta::Attribute::Native::Trait::Number' );
-
-is_deeply(
- $attr->handles,
- {
- set => 'set',
- add => 'add',
- sub => 'sub',
- mul => 'mul',
- div => 'div',
- mod => 'mod',
- abs => 'abs',
- inc => [ add => 1 ],
- dec => [ sub => 1 ],
- odd => [ mod => 2 ],
- cut_in_half => [ div => 2 ],
- },
- '... got the right handles mapping'
-);
+skip_meta {
+ my $attr = $real->meta->get_attribute('integer');
+ does_ok( $attr, 'Moose::Meta::Attribute::Native::Trait::Number' );
+
+ is_deeply(
+ $attr->handles,
+ {
+ set => 'set',
+ add => 'add',
+ sub => 'sub',
+ mul => 'mul',
+ div => 'div',
+ mod => 'mod',
+ abs => 'abs',
+ inc => [ add => 1 ],
+ dec => [ sub => 1 ],
+ odd => [ mod => 2 ],
+ cut_in_half => [ div => 2 ],
+ },
+ '... got the right handles mapping'
+ );
+} 2;
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 43;
use Test::Exception;
use Test::Moose 'does_ok';
+use MetaTest;
+
my $sort;
my $less;
my $up;
is_deeply( [ $other_stuff->unique_options ], [1, 2, 3, 5] );
## test the meta
-
-my $options = $stuff->meta->get_attribute('_options');
-does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Array' );
-
-is_deeply(
- $options->handles,
- {
- 'num_options' => 'count',
- 'has_no_options' => 'is_empty',
- 'map_options', => 'map',
- 'filter_options' => 'grep',
- 'find_option' => 'first',
- 'options' => 'elements',
- 'join_options' => 'join',
- 'get_option_at' => 'get',
- 'sorted_options' => 'sort',
- 'randomized_options' => 'shuffle',
- 'unique_options' => 'uniq',
- 'less_than_five' => [ grep => $less ],
- 'up_by_one' => [ map => $up ],
- 'pairwise_options' => [ natatime => 2 ],
- 'dashify' => [ join => '-' ],
- 'descending' => [ sort => $sort ],
- 'product' => [ reduce => $prod ],
- },
- '... got the right handles mapping'
-);
-
-is( $options->type_constraint->type_parameter, 'Int',
- '... got the right container type' );
+skip_meta {
+ my $options = $stuff->meta->get_attribute('_options');
+ does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Array' );
+
+ is_deeply(
+ $options->handles,
+ {
+ 'num_options' => 'count',
+ 'has_no_options' => 'is_empty',
+ 'map_options', => 'map',
+ 'filter_options' => 'grep',
+ 'find_option' => 'first',
+ 'options' => 'elements',
+ 'join_options' => 'join',
+ 'get_option_at' => 'get',
+ 'sorted_options' => 'sort',
+ 'randomized_options' => 'shuffle',
+ 'unique_options' => 'uniq',
+ 'less_than_five' => [ grep => $less ],
+ 'up_by_one' => [ map => $up ],
+ 'pairwise_options' => [ natatime => 2 ],
+ 'dashify' => [ join => '-' ],
+ 'descending' => [ sort => $sort ],
+ 'product' => [ reduce => $prod ],
+ },
+ '... got the right handles mapping'
+ );
+
+ is( $options->type_constraint->type_parameter, 'Int',
+ '... got the right container type' );
+} 3;
dies_ok {
$stuff->sort_in_place_options(undef);
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 22;
use Test::Moose 'does_ok';
+use MetaTest;
+
my $uc;
{
package MyHomePage;
# check the meta ..
-my $string = $page->meta->get_attribute('string');
-does_ok( $string, 'Moose::Meta::Attribute::Native::Trait::String' );
-
-is(
- $string->type_constraint->name, 'Str',
- '... got the expected type constraint'
-);
-
-is_deeply(
- $string->handles,
- {
- inc_string => 'inc',
- append_string => 'append',
- prepend_string => 'prepend',
- match_string => 'match',
- replace_string => 'replace',
- chop_string => 'chop',
- chomp_string => 'chomp',
- clear_string => 'clear',
- length_string => 'length',
- exclaim => [ append => '!' ],
- capitalize_last => [ replace => qr/(.)$/, $uc ],
- invalid_number => [ match => qr/\D/ ],
- },
- '... got the right handles methods'
-);
+skip_meta {
+ my $string = $page->meta->get_attribute('string');
+ does_ok( $string, 'Moose::Meta::Attribute::Native::Trait::String' );
+
+ is(
+ $string->type_constraint->name, 'Str',
+ '... got the expected type constraint'
+ );
+
+ is_deeply(
+ $string->handles,
+ {
+ inc_string => 'inc',
+ append_string => 'append',
+ prepend_string => 'prepend',
+ match_string => 'match',
+ replace_string => 'replace',
+ chop_string => 'chop',
+ chomp_string => 'chomp',
+ clear_string => 'clear',
+ length_string => 'length',
+ exclaim => [ append => '!' ],
+ capitalize_last => [ replace => qr/(.)$/, $uc ],
+ invalid_number => [ match => qr/\D/ ],
+ },
+ '... got the right handles methods'
+ );
+} 3;