Last active
June 17, 2016 02:30
-
-
Save exodist/72fc7644259cead55c52b3ad7c993ac2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test2::API qw/context run_subtest intercept/; | |
use Test2::Tools::Basic; | |
use strict; | |
use warnings; | |
sub is_int { 1 }; # Stub | |
sub is_even { | |
my ($thing, $name) = @_; | |
my $ctx = context(); | |
my $pass = run_subtest($name, sub { | |
my $st_ctx = context(); | |
$st_ctx->ok(is_int($thing), 'Thing is an int'); | |
$st_ctx->ok(!($thing % 2), "Thing is event"); | |
$st_ctx->release; | |
}, {buffered => 1, inherit_trace => 1}); | |
$ctx->release; | |
return $pass; | |
} | |
my $pass; | |
intercept { $pass = is_even(1, "1 is not even") }; | |
ok(!$pass, "is_event(1) returned false"); | |
ok(is_even(2, "2 is even"), "is_even(2) returned true"); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment