This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
cd4b28dcbed84d596dee340204d2924bc6d93fbf
[perl5.git] / cpan / Test-Simple / lib / Test2 / Event / Encoding.pm
1 package Test2::Event::Encoding;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.302133';
6
7 use Carp qw/croak/;
8
9 BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
10 use Test2::Util::HashBase qw/encoding/;
11
12 sub init {
13     my $self = shift;
14     defined $self->{+ENCODING} or croak "'encoding' is a required attribute";
15 }
16
17 sub summary { 'Encoding set to ' . $_[0]->{+ENCODING} }
18
19 sub facet_data {
20     my $self = shift;
21     my $out = $self->common_facet_data;
22     $out->{control}->{encoding} = $self->{+ENCODING};
23     $out->{about}->{details} = $self->summary;
24     return $out;
25 }
26
27
28 1;
29
30 __END__
31
32 =pod
33
34 =encoding UTF-8
35
36 =head1 NAME
37
38 Test2::Event::Encoding - Set the encoding for the output stream
39
40 =head1 DESCRIPTION
41
42 The encoding event is generated when a test file wants to specify the encoding
43 to be used when formatting its output. This event is intended to be produced
44 by formatter classes and used for interpreting test names, message contents,
45 etc.
46
47 =head1 SYNOPSIS
48
49     use Test2::API qw/context/;
50     use Test2::Event::Encoding;
51
52     my $ctx = context();
53     my $event = $ctx->send_event('Encoding', encoding => 'UTF-8');
54
55 =head1 METHODS
56
57 Inherits from L<Test2::Event>. Also defines:
58
59 =over 4
60
61 =item $encoding = $e->encoding
62
63 The encoding being specified.
64
65 =back
66
67 =head1 SOURCE
68
69 The source code repository for Test2 can be found at
70 F<http://github.com/Test-More/test-more/>.
71
72 =head1 MAINTAINERS
73
74 =over 4
75
76 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
77
78 =back
79
80 =head1 AUTHORS
81
82 =over 4
83
84 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
85
86 =back
87
88 =head1 COPYRIGHT
89
90 Copyright 2018 Chad Granum E<lt>exodist@cpan.orgE<gt>.
91
92 This program is free software; you can redistribute it and/or
93 modify it under the same terms as Perl itself.
94
95 See F<http://dev.perl.org/licenses/>
96
97 =cut