fix incompatibilities with TB2
[gitmo/Moose.git] / t / test_moose / with_immutable_tb2.t
CommitLineData
9153f80b 1use strict;
2use warnings;
3
4use Test::More;
5
6BEGIN {
7 use Test::More;
8 plan skip_all => 'These tests are only for Test::Builder 1.005+'
9 if Test::Builder->VERSION < 1.005;
10}
11
12{
13 package Foo;
14 use Moose;
15}
16
17{
18 package Bar;
19 use Moose;
20}
21
22package main;
23
24use Test::Moose;
25use TB2::Tester;
26use TB2::History; # FIXME - this should not need to be loaded here explicitly
27
28my ($ret1, $ret2);
29my $capture = capture {
30 $ret1 = with_immutable {
31 ok(Foo->meta->is_mutable, 'is mutable');
32 } qw(Foo);
33
34 $ret2 = with_immutable {
35 ok(Bar->meta->find_method_by_name('new'), 'can find "new" method');
36 } qw(Bar);
37};
38
39my $results = $capture->results;
40
41my @tests = (
42 [
43 'first test runs while Foo is mutable' => { name => 'is mutable',
44 is_pass => 1,
45 },
46 ],
47 [
48 'first test runs while Foo is immutable' => { name => 'is mutable',
49 is_pass => 0,
50 },
51 ],
52 [
53 'can find "new" while Bar is mutable' => { name => 'can find "new" method',
54 is_pass => 1,
55 },
56 ],
57 [
58 'can find "new" while Bar is immutable' => { name => 'can find "new" method',
59 is_pass => 1,
60 },
61 ],
62);
63
64result_like(shift(@$results), $_->[1], $_->[0]) foreach @tests;
65
66ok(!$ret1, 'one of the is_immutable tests failed');
67ok($ret2, 'the find_method_by_name tests passed');
68
69done_testing;
70