3 use warnings FATAL => 'all';
5 use Test::More 'no_plan';
11 use Function::Parameters qw(:strict);
13 method add($this = 23, $that = 42) {
17 method minus($this = 23, $that = 42) {
21 is( Stuff->add(), 23 + 42 );
22 is( Stuff->add(99), 99 + 42 );
23 is( Stuff->add(2,3), 5 );
25 is( Stuff->minus(), 23 - 42 );
26 is( Stuff->minus(99), 99 - 42 );
27 is( Stuff->minus(2, 3), 2 - 3 );
30 # Test that undef overrides defaults
31 method echo($message = "what?") {
35 is( Stuff->echo(), "what?" );
36 is( Stuff->echo(undef), undef );
37 is( Stuff->echo("who?"), 'who?' );
40 # Test that you can reference earlier args in a default
41 method copy_cat($this, $that = $this) {
45 is( Stuff->copy_cat("wibble"), "wibble" );
46 is( Stuff->copy_cat(23, 42), 42 );
53 use Function::Parameters qw(:strict);
55 method hello($msg = "Hello, world!") {
59 is( Bar->hello, "Hello, world!" );
60 is( Bar->hello("Greetings!"), "Greetings!" );
63 method hi($msg = q,Hi,) {
68 is( Bar->hi("Yo"), "Yo" );
71 # method list(@args = (1,2,3)) {
75 # is_deeply [Bar->list()], [1,2,3];
78 method code($num, $code = sub { $num + 2 }) {
82 is( Bar->code(42), 44 );