Skip to content

Commit

Permalink
Work in progress on using Test::Stream::Tester
Browse files Browse the repository at this point in the history
  • Loading branch information
autarch committed Jul 18, 2015
1 parent 741d068 commit a210e15
Showing 1 changed file with 77 additions and 41 deletions.
118 changes: 77 additions & 41 deletions t/test_moose/with_immutable.t
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use strict;
use warnings;

use Test::Builder::Tester;
use Test::More;
use Test::Requires {
'Test::Stream::Tester' => 0,
'Test::Builder ' => '1.0302007',
};

use Test::Stream::Tester;
use Test::More;
use Test::Moose;

{
Expand All @@ -17,46 +21,78 @@ use Test::Moose;
}

{
my @expect = split /\n/, <<'EOF';
# Subtest: Foo is not immutable
ok 1
1..1
ok 1 - Foo is not immutable
# Subtest: Foo is immutable
not ok 1
1..1
not ok 2 - Foo is immutable
EOF

test_out(@expect);
test_fail(+4);
my $ret = with_immutable {
ok( Foo->meta->is_mutable );
}
qw(Foo);
test_test('with_immutable failure');
ok( !$ret, 'one of our tests failed' );
events_are(
intercept {
with_immutable {
ok( Foo->meta->is_mutable );
}
'Foo';
},
events {
event 'Subtest' => sub {
event_call diag => [qr/Foo is not immutable/];
event_call subevents => events {
event Ok => sub {
event_call pass => 1;
};
event Plan => { max => 1 };
};
};
event 'Subtest' => sub {
event_call diag => [qr/Foo is immutable/];
event_call subevents => events {
event Ok => sub {
event_call pass => 0;
};
event Plan => { max => 1 };
};
};
event Plan => { max => 2 };
},
);
}

{
my @expect = split /\n/, <<'EOF';
# Subtest: Bar is not immutable
ok 1
1..1
ok 1 - Bar is not immutable
# Subtest: Bar is immutable
ok 1
1..1
ok 2 - Bar is immutable
EOF

test_out(@expect);
my $ret = with_immutable {
ok( Bar->meta->find_method_by_name('new') );
}
qw(Bar);
test_test('with_immutable success');
ok( $ret, "all tests succeeded" );
}

# my @expect = split /\n/, <<'EOF';
# # Subtest: Foo is not immutable
# ok 1
# 1..1
# ok 1 - Foo is not immutable
# # Subtest: Foo is immutable
# not ok 1
# 1..1
# not ok 2 - Foo is immutable
# EOF

# test_out(@expect);
# test_fail(+4);
# my $ret = with_immutable {
# ok( Foo->meta->is_mutable );
# }
# qw(Foo);
# test_test('with_immutable failure');
# ok( !$ret, 'one of our tests failed' );
# }

# {
# my @expect = split /\n/, <<'EOF';
# # Subtest: Bar is not immutable
# ok 1
# 1..1
# ok 1 - Bar is not immutable
# # Subtest: Bar is immutable
# ok 1
# 1..1
# ok 2 - Bar is immutable
# EOF

# test_out(@expect);
# my $ret = with_immutable {
# ok( Bar->meta->find_method_by_name('new') );
# }
# qw(Bar);
# test_test('with_immutable success');
# ok( $ret, "all tests succeeded" );
# }

done_testing;

0 comments on commit a210e15

Please sign in to comment.