From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#!perl
BEGIN
{
use strict;
use warnings;
use lib './lib';
use vars qw( $DEBUG );
use Test2::V0;
use Module::Generic::File qw( file tempfile );
our $DEBUG = exists( $ENV{AUTHOR_TESTING} ) ? $ENV{AUTHOR_TESTING} : 0;
};
use strict;
my $f = file( __FILE__ )->parent->child( 'testin/mignonne-ronsard.txt' );
my $check = file( __FILE__ )->parent->child( 'testin/mignonne-ronsard.txt.qp' )->load;
my $str = $f->load;
diag( "String is:\n$str" ) if( $DEBUG );
my $s = HTTP::Promise::Stream::QuotedPrint->new( debug => $DEBUG );
isa_ok( $s => ['HTTP::Promise::Stream::QuotedPrint'] );
my $enc = Module::Generic::Scalar->new;
my $rv = $s->encode( $f => $enc, eol => "\012" );
diag( "QuotedPrint text is:\n$enc" ) if( $DEBUG );
is( "$enc" => $check );
my $dec = Module::Generic::Scalar->new;
my $dec_io = $dec->open( '>' );
$s->decode( $enc => $dec_io );
is( "$dec" => $str );
done_testing();
__END__