File: moose.t

package info (click to toggle)
libbadger-perl 0.16-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,400 kB
  • sloc: perl: 11,004; makefile: 9
file content (61 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#============================================================= -*-perl-*-
#
# t/misc/moose.t
#
# Tests to show Badger plays nicely with Moose.
#
# Written by Andy Wardley <abw@wardley.org>
#
# Copyright (C) 2008 Andy Wardley.  All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
#========================================================================

use strict;
use warnings;
use lib qw( ./lib ../lib ../../lib );
use Badger::Test
    skip  => 'Moose is borken? (invalid version format)',
    debug => 'Badger',
    args  => \@ARGV;

BEGIN {
    eval "use Moose ()";
    skip_all("You don't have Moose installed, shame on you!") if $@;
    plan(6);
}

package Badger::Test::Moose::One;
use Moose;
use Badger::Class
    version   => 1.23,
    debug     => 0,
    accessors => 'bar',
    mutators  => 'baz',
    import    => 'class',
    words     => 'HELLO WORLD';

extends 'Badger::Base';
has foo => (is => 'rw');
our $BAZ = 3.14;

sub init {
    my ($self, $config) = @_;
    for (qw( foo bar baz )) {
        $self->{ $_ } = $config->{ $_ }
            || $self->class->any_var(uc $_);
    }
    return $self;
}
    
package main;

my $one = Badger::Test::Moose::One->new( foo => 10, bar => 20 );
ok( $one, 'created first object' );
is( $one->foo, 10, 'foo is 10' );
is( $one->bar, 20, 'bar is 10' );
is( $one->baz, 3.14, 'baz is 3.14' );
is( $one->baz(30), 30, 'set baz to 30' );
is( $one->baz, 30, 'baz is 30' );