Regenerate test files
[gitmo/Mouse.git] / t-failing / 020_attributes / 028_no_slot_access.t
CommitLineData
4060c871 1#!/usr/bin/perl
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
4060c871 5
6use strict;
7use warnings;
8
9{
10 package SomeAwesomeDB;
11
12 sub new_row { }
13 sub read { }
14 sub write { }
15}
16
17{
fde8e43f 18 package MooseX::SomeAwesomeDBFields;
4060c871 19
20 # implementation of methods not called in the example deliberately
21 # omitted
22
23 use Mouse::Role;
24
25 sub inline_create_instance {
26 my ( $self, $classvar ) = @_;
27
28 "bless SomeAwesomeDB::new_row(), $classvar";
29 }
30
31 sub inline_get_slot_value {
32 my ( $self, $invar, $slot ) = @_;
33
34 "SomeAwesomeDB::read($invar, \"$slot\")";
35 }
36
37 sub inline_set_slot_value {
38 my ( $self, $invar, $slot, $valexp ) = @_;
39
40 "SomeAwesomeDB::write($invar, \"$slot\", $valexp)";
41 }
42
43 sub inline_is_slot_initialized {
44 my ( $self, $invar, $slot ) = @_;
45
46 "1";
47 }
48
49 sub inline_initialize_slot {
50 my ( $self, $invar, $slot ) = @_;
51
52 "";
53 }
54
55 sub inline_slot_access {
56 die "inline_slot_access should not have been used";
57 }
58}
59
60{
61 package Toy;
62
63 use Mouse;
64 use Mouse::Util::MetaRole;
65
fde8e43f 66 use Test::More;
67$TODO = q{Mouse is not yet completed};
4060c871 68 use Test::Exception;
69
fde8e43f 70 Mouse::Util::MetaRole::apply_metaroles(
71 for => __PACKAGE__,
72 class_metaroles => { instance => ['MooseX::SomeAwesomeDBFields'] },
4060c871 73 );
74
75 lives_ok {
76 has lazy_attr => (
77 is => 'ro',
78 isa => 'Bool',
79 lazy => 1,
80 default => sub {0},
81 );
82 }
83 "Adding lazy accessor does not use inline_slot_access";
84
85 lives_ok {
86 has rw_attr => (
87 is => 'rw',
88 );
89 }
90 "Adding read-write accessor does not use inline_slot_access";
91
92 lives_ok { __PACKAGE__->meta->make_immutable; }
93 "Inling constructor does not use inline_slot_access";
fde8e43f 94
95 done_testing;
4060c871 96}