This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Test-Simple to CPAN version 1.302181
[perl5.git] / cpan / Test-Simple / lib / Test2 / Event / Pass.pm
1 package Test2::Event::Pass;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.302182';
6
7 use Test2::EventFacet::Info;
8
9 BEGIN {
10     require Test2::Event;
11     our @ISA = qw(Test2::Event);
12     *META_KEY = \&Test2::Util::ExternalMeta::META_KEY;
13 }
14
15 use Test2::Util::HashBase qw{ -name -info };
16
17 ##############
18 # Old API
19 sub summary          { "pass" }
20 sub increments_count { 1 }
21 sub causes_fail      { 0 }
22 sub diagnostics      { 0 }
23 sub no_display       { 0 }
24 sub subtest_id       { undef }
25 sub terminate        { () }
26 sub global           { () }
27 sub sets_plan        { () }
28
29 ##############
30 # New API
31
32 sub add_info {
33     my $self = shift;
34
35     for my $in (@_) {
36         $in = {%$in} if ref($in) ne 'ARRAY';
37         $in = Test2::EventFacet::Info->new($in);
38
39         push @{$self->{+INFO}} => $in;
40     }
41 }
42
43 sub facet_data {
44     my $self = shift;
45
46     my $out = $self->common_facet_data;
47
48     $out->{about}->{details} = 'pass';
49
50     $out->{assert} = {pass => 1, details => $self->{+NAME}};
51
52     $out->{info} = [map {{ %{$_} }} @{$self->{+INFO}}] if $self->{+INFO};
53
54     return $out;
55 }
56
57 1;
58
59 __END__
60
61 =pod
62
63 =encoding UTF-8
64
65 =head1 NAME
66
67 Test2::Event::Pass - Event for a simple passing assertion
68
69 =head1 DESCRIPTION
70
71 This is an optimal representation of a passing assertion.
72
73 =head1 SYNOPSIS
74
75     use Test2::API qw/context/;
76
77     sub pass {
78         my ($name) = @_;
79         my $ctx = context();
80         $ctx->pass($name);
81         $ctx->release;
82     }
83
84 =head1 SOURCE
85
86 The source code repository for Test2 can be found at
87 F<http://github.com/Test-More/test-more/>.
88
89 =head1 MAINTAINERS
90
91 =over 4
92
93 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
94
95 =back
96
97 =head1 AUTHORS
98
99 =over 4
100
101 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
102
103 =back
104
105 =head1 COPYRIGHT
106
107 Copyright 2020 Chad Granum E<lt>exodist@cpan.orgE<gt>.
108
109 This program is free software; you can redistribute it and/or
110 modify it under the same terms as Perl itself.
111
112 See F<http://dev.perl.org/licenses/>
113
114 =cut