@@ -524,6 +524,73 @@ $txt =~ s/\s//g;
524524is(" $txt " , ' ---no:falseyes:true' ,
525525 " yaml module renders booleans true/false correctly when using prefixing" );
526526
527+ =pod
528+
529+ =head3 yamlmulti
530+
531+ Test yaml/YAML::XS multi-documents
532+
533+ =cut
534+
535+ my $multicontents = {
536+ ' doc0' => {
537+ ' name_level0_doc0' => ' value_level0_doc0' ,
538+ ' level1_doc0' => {
539+ ' name_level1_doc0' => ' value_level1_doc0' ,
540+ }
541+ },
542+ ' doc1' => {
543+ ' name_level0_doc1' => ' value_level0_doc1' ,
544+ ' level1_doc1' => {
545+ ' name_level1_doc1' => ' value_level1_doc1' ,
546+ }
547+ }
548+ };
549+
550+
551+ my $multires = <<EOF ;
552+ ---
553+ level1_doc0:
554+ name_level1_doc0: value_level1_doc0
555+ name_level0_doc0: value_level0_doc0
556+ ---
557+ level1_doc1:
558+ name_level1_doc1: value_level1_doc1
559+ name_level0_doc1: value_level0_doc1
560+ EOF
561+ $trd = CAF::TextRender-> new(' yamlmulti' , $multicontents );
562+ ok($trd -> load_module(' YAML::XS' ), " YAML::XS loaded" );
563+ ok(! $trd -> {method_is_tt }, " method_is_tt false for yamlmulti" );
564+ is(" $trd " , $multires , " yamlmulti module rendered correctly" );
565+
566+ # true/false tests
567+ $trd = CAF::TextRender-> new(' yamlmulti' , {' a' => $YAML_BOOL }, eol => 0);
568+ $txt = " $trd " ;
569+ $txt =~ s /\s // g ;
570+ is($txt , ' ---no:falseyes:true' ,
571+ " yamlmulti module renders booleans true/false correctly" );
572+
573+ # but this goes wrong
574+ $trd = CAF::TextRender-> new(' yamlmulti' , {
575+ ' a' => {' yes' => $YAML_BOOL -> {' yes' }},
576+ ' b' => {' no' => $YAML_BOOL -> {' no' }},
577+ }, eol => 0);
578+
579+ $txt = " $trd " ;
580+ $txt =~ s /\s // g ;
581+ is(" $txt " , " ---yes:1---no:''" ,
582+ " yamlmulti module renders booleans true/false incorrect when constructing hashref" );
583+
584+ # so use the CAF::TextRender prefixing
585+ $trd = CAF::TextRender-> new(' yamlmulti' , {
586+ ' a' => {' yes' => $YAML_BOOL_PREFIX ." true" },
587+ ' b' => {' no' => $YAML_BOOL_PREFIX ." false" },
588+ }, eol => 0);
589+ $txt = " $trd " ;
590+ $txt =~ s /\s // g ;
591+ is(" $txt " , ' ---yes:true---no:false' ,
592+ " yamlmulti module renders booleans true/false correctly when using prefixing" );
593+
527594
528595=pod
529596
0 commit comments