#!/usr/bin/perl
-package SomeAwesomeDB;
+use strict;
+use warnings;
-sub new_row { }
-sub read { }
-sub write { }
+{
+ package SomeAwesomeDB;
-package MooseX::SomeAwesomeDBFields;
+ sub new_row { }
+ sub read { }
+ sub write { }
+}
-use Moose::Role;
+{
+ package MooseX::SomeAwesomeDBFields;
-sub inline_create_instance {
- my ($self, $classvar) = @_;
+ # implementation of methods not called in the example deliberately
+ # omitted
- "bless SomeAwesomeDB::new_row(), $classvar";
-}
+ use Moose::Role;
-sub inline_get_slot_value {
- my ($self, $invar, $slot) = @_;
+ sub inline_create_instance {
+ my ( $self, $classvar ) = @_;
- "SomeAwesomeDB::read($invar, \"$slot\")";
-}
+ "bless SomeAwesomeDB::new_row(), $classvar";
+ }
-sub inline_set_slot_value {
- my ($self, $invar, $slot, $valexp) = @_;
+ sub inline_get_slot_value {
+ my ( $self, $invar, $slot ) = @_;
- "SomeAwesomeDB::write($invar, \"$slot\", $valexp)";
-}
+ "SomeAwesomeDB::read($invar, \"$slot\")";
+ }
-sub inline_is_slot_initialized {
- my ($self, $invar, $slot) = @_;
+ sub inline_set_slot_value {
+ my ( $self, $invar, $slot, $valexp ) = @_;
- "1";
-}
+ "SomeAwesomeDB::write($invar, \"$slot\", $valexp)";
+ }
-sub inline_initialize_slot {
- my ($self, $invar, $slot) = @_;
+ sub inline_is_slot_initialized {
+ my ( $self, $invar, $slot ) = @_;
- "";
-}
+ "1";
+ }
-sub inline_slot_access {
- die "inline_slot_access should not have been used";
-}
+ sub inline_initialize_slot {
+ my ( $self, $invar, $slot ) = @_;
-# implementation of methods not called in the example deliberately
-# omitted
+ "";
+ }
-package Toy;
+ sub inline_slot_access {
+ die "inline_slot_access should not have been used";
+ }
+}
-use Moose;
-use Moose::Util::MetaRole;
+{
+ package Toy;
-use Test::More tests => 3;
-use Test::Exception;
+ use Moose;
+ use Moose::Util::MetaRole;
-Moose::Util::MetaRole::apply_metaclass_roles
- (for_class => __PACKAGE__,
- instance_metaclass_roles => [ 'MooseX::SomeAwesomeDBFields' ]);
+ use Test::More tests => 3;
+ use Test::Exception;
-lives_ok {
- has lazy_attr => (
- is => 'ro',
- isa => 'Bool',
- lazy => 1,
- default => sub { 0 },
+ Moose::Util::MetaRole::apply_metaclass_roles(
+ for_class => __PACKAGE__,
+ instance_metaclass_roles => ['MooseX::SomeAwesomeDBFields']
);
-} "Adding lazy accessor does not use inline_slot_access";
-lives_ok {
- has rw_attr => (
- is => 'rw',
- );
-} "Adding read-write accessor does not use inline_slot_access";
-
-lives_ok { __PACKAGE__->meta->make_immutable; }
+ lives_ok {
+ has lazy_attr => (
+ is => 'ro',
+ isa => 'Bool',
+ lazy => 1,
+ default => sub {0},
+ );
+ }
+ "Adding lazy accessor does not use inline_slot_access";
+
+ lives_ok {
+ has rw_attr => (
+ is => 'rw',
+ );
+ }
+ "Adding read-write accessor does not use inline_slot_access";
+
+ lives_ok { __PACKAGE__->meta->make_immutable; }
"Inling constructor does not use inline_slot_access";
+}