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

#!/usr/bin/env perl
# Copyright (c) 2014-2015 Christian Jaeger, copying@christianjaeger.ch
# This is free software. See the file COPYING.md that came bundled
# with this file.
use strict;
use warnings FATAL => 'uninitialized';
our ($mydir, $myname);
BEGIN {
$0 =~ /(.*?)([^\/]+)\z/s or die "?";
($mydir, $myname) = ($1, $2);
}
use lib "$mydir/../../lib";
use Chj::TEST ":all";
use PXML::XHTML ":all";
use PXML::Serialize "pxml_print_fragment_fast";
use FP::Array ":all"; # XXX inconsistency in export directives
TEST_STDOUT {
pxml_print_fragment_fast(A({ href => "hah" }, "Hello ", I("World", B("!"))),
*STDOUT{IO})
}
'<a href="hah">Hello <i>World<b>!</b></i></a>';
TEST {
A(
{ href => "hah" },
"Hello ",
I("World", undef, B("!")),
cons(" ", string_to_stream("You're great."))
)->text
}
'Hello World! You\'re great.';
TEST { P(list)->string }
'<p></p>';
TEST { P(list 1, 2, B(3))->string }
'<p>12<b>3</b></p>';
TEST {
P(stream 1, 2, lazy { B(3) })->string
}
'<p>12<b>3</b></p>';
TEST { P(array 1, 2, B(3))->string }
'<p>12<b>3</b></p>';
TEST { P(purearray 1, 2, B(3))->string }
'<p>12<b>3</b></p>';
TEST { P(cons "Hello", "World")->string }
'<p>HelloWorld</p>';
TEST { P(cons I("Hello"), B(cons null, "World"))->string }
'<p><i>Hello</i><b>World</b></p>';
perhaps_run_tests(__PACKAGE__) or do {
require FP::Repl;
FP::Repl::repl();
};