Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test combined positional and named params.
- Loading branch information
Showing
2 changed files
with
23 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,42 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More tests => 17; | ||
use Test::More tests => 20; | ||
use Test::Exception; | ||
|
||
use FindBin; | ||
use lib "$FindBin::Bin/lib"; | ||
|
||
use TestClass; | ||
|
||
dies_ok(sub { | ||
TestClass->new; | ||
}); | ||
|
||
dies_ok(sub { | ||
TestClass->new('moo', 23); | ||
}); | ||
|
||
dies_ok(sub { | ||
TestClass->new('moo', 8); | ||
}); | ||
|
||
lives_ok(sub { | ||
TestClass->new('moo', 52); | ||
}); | ||
dies_ok(sub { TestClass->new }); | ||
dies_ok(sub { TestClass->new('moo', 23) }); | ||
dies_ok(sub { TestClass->new('moo', 8) }); | ||
lives_ok(sub { TestClass->new('moo', 52) }); | ||
|
||
my $o = TestClass->new('foo'); | ||
isa_ok($o, 'TestClass'); | ||
|
||
is($o->{foo}, 'foo'); | ||
is($o->{bar}, 42); | ||
|
||
lives_ok(sub { | ||
$o->set_bar(23); | ||
}); | ||
lives_ok(sub { $o->set_bar(23) }); | ||
is($o->{bar}, 23); | ||
|
||
dies_ok(sub { | ||
$o->set_bar('bar'); | ||
}); | ||
|
||
lives_ok(sub { | ||
$o->affe({ foo => 1 }); | ||
}); | ||
|
||
lives_ok(sub { | ||
$o->affe([qw/a b c/]); | ||
}); | ||
|
||
dies_ok(sub { | ||
$o->affe('foo'); | ||
}); | ||
dies_ok(sub { $o->set_bar('bar') }); | ||
|
||
dies_ok(sub { | ||
$o->positional; | ||
}); | ||
lives_ok(sub { $o->affe({ foo => 1 }) }); | ||
lives_ok(sub { $o->affe([qw/a b c/]) }); | ||
dies_ok(sub { $o->affe('foo') }); | ||
|
||
dies_ok(sub { | ||
$o->positional(optional => 42); | ||
}); | ||
dies_ok(sub { $o->positional }); | ||
dies_ok(sub { $o->positional(optional => 42) }); | ||
lives_ok(sub { $o->positional(required => 23) }); | ||
lives_ok(sub { $o->positional(optional => 42, required => 23) }); | ||
|
||
lives_ok(sub { | ||
$o->positional(required => 23); | ||
}); | ||
dies_ok(sub { $o->combined(1, 2) }); | ||
dies_ok(sub { $o->combined(1, required => 2) }); | ||
lives_ok(sub { $o->combined(1, 2, 3, required => 4, optional => 5) }); | ||
|
||
lives_ok(sub { | ||
$o->positional(optional => 42, required => 23); | ||
}); | ||
# MooseX::Meta::Signature::Combined bug? optional positional can't be omitted | ||
#lives_ok(sub { $o->combined(1, 2, required => 3) }); | ||
#lives_ok(sub { $o->combined(1, 2, required => 3, optional => 4) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters