File: 05-request.t

package info (click to toggle)
libhtml-mason-perl 1%3A1.58-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,796 kB
  • sloc: perl: 8,618; sh: 49; makefile: 2
file content (988 lines) | stat: -rw-r--r-- 25,094 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
use strict;
use warnings;

use HTML::Mason::Tests;

my $tests = make_tests();
$tests->run;

sub make_tests
{
    my $group = HTML::Mason::Tests->tests_class->new( name => 'request',
                                                      description => 'request object functionality' );


#------------------------------------------------------------

    $group->add_support( path => '/support/abort_test',
                         component => <<'EOF',
<%args>
$val => 50
</%args>
Some more text

% $m->abort($val);

But this will never be seen
EOF
                       );


#------------------------------------------------------------

    $group->add_support( path => '/sections/perl',
                         component => <<'EOF',
foo
EOF
                       );


#------------------------------------------------------------

    $group->add_support( path => '/support/various_test',
                         component => <<'EOF',
Caller is <% $m->caller->title %> or <% $m->callers(1)->title %> or <% $m->callers(-2)->title %>.
The top level component is <% $m->callers(-1)->title %> or <% $m->request_comp->title %>.
The full component stack is <% join(",",map($_->title,$m->callers)) %>.
My argument list is (<% join(",",$m->caller_args(0)) %>).
The top argument list is (<% join(",",$m->request_args()) %>) or (<% join(",",$m->caller_args(-1)) %>).

% foreach my $path (qw(various_test /request/sections/perl foobar /shared)) {
%   my $full_path = HTML::Mason::Tools::absolute_comp_path($path, $m->current_comp->dir_path);
Trying to fetch <% $path %> (full path <% $full_path %>):
%   if ($m->comp_exists($path)) {
%     if (my $comp = $m->fetch_comp($path)) {
<% $path %> exists with title <% $comp->title %>.
%     } else {
<% $path %> exists but could not fetch object!
%     }
%   } else {
<% $path %> does not exist.
%   }
% }

% $m->print("Output via the out function.");

/request/file outputs <% int(length($m->scomp("/request/file"))/10) %>0+ characters.
EOF
                       );


#------------------------------------------------------------

    $group->add_support( path => 'various_helper',
                         component => <<'EOF',
<& support/various_test, %ARGS &>
EOF
                       );

#------------------------------------------------------------

    $group->add_test( name => 'abort',
                      description => 'test $m->abort method (autoflush on)',
                      interp_params => { autoflush => 1 },
                      component => <<'EOF',
Some text

% eval {$m->comp('support/abort_test')};
% if (my $err = $@) {
%   if ($m->aborted) {
Component aborted with value <% $err->aborted_value %>
%   } else {
Got error
%   }
% }
EOF
                      expect => <<'EOF',
Some text

Some more text

Component aborted with value 50
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'abort_0',
                      description => 'test $m->abort method with value of 0',

                      component => <<'EOF',
Some text

% eval {$m->comp('support/abort_test', val => 0)};
% if (my $err = $@) {
%   if ($m->aborted($err)) {
Component aborted with value <% $err->aborted_value %>
%   } else {
Got error
%   }
% }
EOF
                      expect => <<'EOF',
Some text

Some more text

Component aborted with value 0
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'abort',
                      description => 'test $m->abort method (autoflush off)',
                      component => <<'EOF',
Some text

% eval {$m->comp('support/abort_test')};
% if (my $err = $@) {
%   if ($m->aborted) {
Component aborted with value <% $err->aborted_value %>
%   } else {
Got error
%   }
% }
EOF
                      expect => <<'EOF',
Some text

Some more text

Component aborted with value 50
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'file',
                      description => 'tests $m->file method',
                      component => <<'EOF',
Now I will print myself:

% my $output = $m->file("file");
% $output =~ s/\cM//g;
<% $output %>
EOF
                      expect => <<'EOF',
Now I will print myself:

Now I will print myself:

% my $output = $m->file("file");
% $output =~ s/\cM//g;
<% $output %>
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'file_in_subcomp',
                      description => 'tests $m->file method in subcomponent',
                      component => <<'EOF',
Here I am:

<& .sub &>
<%def .sub>
% my $f = $m->file('file_in_subcomp'); $f =~ s/\r\n?/\n/g;
<% $f %>
</%def>
EOF
                      expect => <<'EOF',
Here I am:


Here I am:

<& .sub &>
<%def .sub>
% my $f = $m->file('file_in_subcomp'); $f =~ s/\r\n?/\n/g;
<% $f %>
</%def>
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'list_out',
                      description => 'tests that $m->print can handle a list of arguments',
                      component => <<'EOF',
Sending list of arguments:

<% 'blah','boom','bah' %>

<%perl>
 $m->print(3,4,5);
 my @lst = (7,8,9);
 $m->print(@lst);
</%perl>
EOF
                      expect => <<'EOF',
Sending list of arguments:

blahboombah

345789
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'req_obj',
                      description => 'tests various operations such as comp calls, $m->current_comp',
                      component => <<'EOF',
<%def .subcomp>
% if ($count < 5) {
<& $m->current_comp, count=>$count+1 &>
% } else {
<& /shared/display_req_obj &>
% }
<%args>
$count
</%args>
</%def>

<% '-' x 10 %>

One level request:
<& /shared/display_req_obj &>

<% '-' x 10 %>

Many level request:
<& .subcomp, count=>0 &>

<% '-' x 10 %>
EOF
                      expect => <<'EOF',

----------

One level request:
My depth is 2.

I am not a subrequest.

The top-level component is /request/req_obj.

My stack looks like:
-----
/shared/display_req_obj
/request/req_obj
-----



----------

Many level request:






My depth is 8.

I am not a subrequest.

The top-level component is /request/req_obj.

My stack looks like:
-----
/shared/display_req_obj
/request/req_obj:.subcomp
/request/req_obj:.subcomp
/request/req_obj:.subcomp
/request/req_obj:.subcomp
/request/req_obj:.subcomp
/request/req_obj:.subcomp
/request/req_obj
-----









----------
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'various',
                      call_args => {junk=>5},
                      description => 'tests caller, callers, fetch_comp, process_comp_path, comp_exists and scomp',
                      component => <<'EOF',
<& various_helper, junk=>$ARGS{junk}+1 &>
EOF
                      expect => <<'EOF',
Caller is /request/various_helper or /request/various_helper or /request/various_helper.
The top level component is /request/various or /request/various.
The full component stack is /request/support/various_test,/request/various_helper,/request/various.
My argument list is (junk,6).
The top argument list is (junk,5) or (junk,5).

Trying to fetch various_test (full path /request/support/various_test):
various_test exists with title /request/support/various_test.
Trying to fetch /request/sections/perl (full path /request/sections/perl):
/request/sections/perl exists with title /request/sections/perl.
Trying to fetch foobar (full path /request/support/foobar):
foobar does not exist.
Trying to fetch /shared (full path /shared):
/shared does not exist.

Output via the out function.
/request/file outputs 120+ characters.
EOF
                    );

#------------------------------------------------------------

    $group->add_support( path => '/autohandler_test2/autohandler',
                         component => <<'EOF',
This is the first autohandler
Remaining chain: <% join(',',map($_->title,$m->fetch_next_all)) %>
<& $m->fetch_next, level => 1 &>\
EOF
                       );

#------------------------------------------------------------

    $group->add_support( path => '/autohandler_test2/dir1/autohandler',
                         component => <<'EOF',
This is the second autohandler
Remaining chain: <% join(',',map($_->title,$m->fetch_next_all)) %>
% foreach (@_) {
<% $_ %>
% }
<& $m->fetch_next, level => 2 &>\
EOF
                       );

#------------------------------------------------------------

    $group->add_test( name => 'fetch_next',
                      path => '/autohandler_test2/dir1/fetch_next',
                      call_path => '/autohandler_test2/dir1/fetch_next',
                      description => 'Test $m->fetch_next and $m->fetch_next_all',
                      component => <<'EOF',
This is the main component (called by level <% $ARGS{level} %>)
Remaining chain: <% join(',',map($_->title,$m->fetch_next_all)) %>
% foreach (@_) {
<% $_ %>
% }
EOF
                      expect => <<'EOF',
This is the first autohandler
Remaining chain: /request/autohandler_test2/dir1/autohandler,/request/autohandler_test2/dir1/fetch_next
This is the second autohandler
Remaining chain: /request/autohandler_test2/dir1/fetch_next
level
1
This is the main component (called by level 2)
Remaining chain: 
level
2
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'print',
                      description => 'Test print function from a component',
                      component => <<'EOF',
This is first.
% print "This is second.\n";
This is third.
EOF
                      expect => <<'EOF',
This is first.
This is second.
This is third.
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'printf',
                      description => 'Test printf function from a component',
                      component => <<'EOF',
This is first.
% printf '%s', "This is second.\n";
This is third.
EOF
                      expect => <<'EOF',
This is first.
This is second.
This is third.
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'autoflush_print',
                      description => 'Test print function from a component with autoflush on',
                      interp_params => { autoflush => 1 },
                      component => <<'EOF',
This is first.
% print "This is second.\n";
This is third.
EOF
                      expect => <<'EOF',
This is first.
This is second.
This is third.
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'autoflush_printf',
                      description => 'Test printf function from a component with autoflush on',
                      interp_params => { autoflush => 1 },
                      component => <<'EOF',
This is first.
% printf '%s', "This is second.\n";
This is third.
EOF
                      expect => <<'EOF',
This is first.
This is second.
This is third.
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'flush_print',
                      description => 'Test print function from a component in conjunction with $m->flush_buffer call',
                      component => <<'EOF',
This is first.
% print "This is second.\n";
% $m->flush_buffer;
This is third.
EOF
                      expect => <<'EOF',
This is first.
This is second.
This is third.
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'flush_print_autoflush',
                      description => 'Test print function from a component with autoflush on in conjunction with $m->flush_buffer call',
                      interp_params => { autoflush => 1 },
                      component => <<'EOF',
This is first.
% print "This is second.\n";
% $m->flush_buffer;
This is third.
EOF
                      expect => <<'EOF',
This is first.
This is second.
This is third.
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'flush_filter',
                      description => 'Test $m->flush_buffer in presence of filter',
                      component => <<'EOF',
one
% $m->flush_buffer;
% $m->clear_buffer;
two
<%filter>
$_ .= $_;
</%filter>
EOF
                      expect => <<'EOF',
one
one
two
two
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'clear_buffer',
                      description => 'Test $m->clear_buffer in a normal component',
                      component => <<'EOF',
one
% $m->clear_buffer;
two
EOF
                      expect => <<'EOF',
two
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'clear_filter',
                      description => 'Test $m->clear_buffer in presence of filter',
                      component => <<'EOF',
one
% $m->clear_buffer;
two
<%filter>
$_ .= $_;
</%filter>
EOF
                      expect => <<'EOF',
two
two
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'autoflush_disabled',
                      description => 'Using autoflush when disabled generates an error',
                      interp_params => { autoflush => 1, enable_autoflush => 0 },
                      component => <<'EOF',
Hi
EOF
                      expect_error => qr/Cannot use autoflush unless enable_autoflush is set/,
                    );

#------------------------------------------------------------

    $group->add_test( name => 'instance',
                      description => 'Test HTML::Mason::Request->instance',
                      component => <<'EOF',
<% $m eq HTML::Mason::Request->instance ? 'yes' : 'no' %>
EOF
                      expect => <<'EOF',
yes
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'abort_and_filter',
                      description => 'Test that an abort in a filtered component still generates _some_ output, and that filter is run only once',
                      component => <<'EOF',
filter

% eval { $m->comp('support/abort_test') };
<%filter>
$_ = uc $_;
$_ =~ s/\s+$//;
$_ .= "\nfilter ran once";
</%filter>
EOF
                      expect => <<'EOF',
FILTER

SOME MORE TEXT
filter ran once
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'abort_and_filter_2',
                      description => 'Test that $m->aborted can be checked in a filter section',
                      component => <<'EOF',
filter

% $m->abort;
<%filter>
unless ( $m->aborted )
{
    $_ = uc $_;
    $_ =~ s/\s+$//;
    $_ .= "\nfilter ran once";
}
</%filter>
EOF
                      expect => <<'EOF',
filter
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'abort_and_store',
                      description => 'Test that an abort in a store\'d component still generates _some_ output',
                      component => <<'EOF',
filter

% my $foo;
% eval { $m->comp( { store => \$foo }, 'support/abort_test') };
<% $foo %>
EOF
                      expect => <<'EOF',
filter

Some more text

EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'clear_and_abort',
                      description => 'Test the clear_and_abort() method',
                      component => <<'EOF',
Some output
% $m->flush_buffer;
More output
% $m->clear_and_abort();
EOF
                      expect => <<'EOF',
Some output
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'reexec',
                      description => 'test that $m cannot be reexecuted',
                      component => <<'EOF',
<%init>
$m->exec;
</%init>
EOF
                      expect_error => qr/Can only call exec\(\) once/,
                    );

#------------------------------------------------------------

    $group->add_test( name => 'caller_in_subcomp',
                      description => 'tests $m->caller() in subcomponent',
                      component => <<'EOF',
<%def .foo>
 <% $m->caller->name %>
</%def>
<& .foo &>
EOF
                      expect => <<'EOF',

 caller_in_subcomp
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'caller_at_top_level',
                      description => 'tests $m->caller() from top component',
                      component => <<'EOF',
caller is <% defined($m->caller) ? "defined" : "undefined" %>
callers(5) is <% defined($m->callers(5)) ? "defined" : "undefined" %>
caller_args(7) is <% defined($m->callers(7)) ? "defined" : "undefined" %>
EOF
                      expect => <<'EOF',
caller is undefined
callers(5) is undefined
caller_args(7) is undefined
EOF
                    );


#------------------------------------------------------------

    $group->add_support( path => '/support/longjump_test3',
                         component => <<'EOF',
Depth is <% $m->depth %>.
The full component stack is <% join(",",map($_->title,$m->callers)) %>.
EOF
                       );

    $group->add_support( path => '/support/subdir/longjump_test2',
                         component => <<'EOF',
This is longjump_test2
% no warnings 'uninitialized'; next;
EOF
                       );

    $group->add_support( path => '/support/longjump_test1',
                         component => <<'EOF',
<& longjump_test3 &>
% foreach my $i (0..2) {
<& subdir/longjump_test2 &>
% }
<& longjump_test3 &>
EOF
                       );

    # It is possible to accidentally call 'next' from a component and
    # jump out to the last loop or block in a previous component.
    # While this cannot be supported behavior (since necessary cleanup
    # and plugin code is skipped), we'd like to avoid a Mason request
    # stack corruption at a minimum.
    #
    $group->add_test( name => 'longjump',
                      description => 'Accidentally calling next to exit a component does not corrupt stack',
                      component => <<'EOF',
<& support/longjump_test1 &>
EOF
                      expect => <<'EOF',
Depth is 3.
The full component stack is /request/support/longjump_test3,/request/support/longjump_test1,/request/longjump.

This is longjump_test2

This is longjump_test2

This is longjump_test2

Depth is 3.
The full component stack is /request/support/longjump_test3,/request/support/longjump_test1,/request/longjump.
EOF
                      # This just shuts the test code up
                      expect_warnings => qr/.*/,
                    );

#------------------------------------------------------------

    $group->add_support( path => '/support/callers_out_of_bounds2',
                         component => <<'EOF',
hi
EOF
                       );

#------------------------------------------------------------

    $group->add_support( path => '/support/callers_out_of_bounds1',
                         component => <<'EOF',
<& callers_out_of_bounds2 &>
% foreach my $i (-4 .. 4) {
callers(<% $i %>) is <% defined($m->callers($i)) ? $m->callers($i)->title : 'not defined' %>
% }
EOF
                       );

#------------------------------------------------------------

    $group->add_test( name => 'callers_out_of_bounds',
                      description => 'tests $m->callers() for out of bounds indexes',
                      component => <<'EOF',
<& support/callers_out_of_bounds1 &>
EOF
                      expect => <<'EOF',
hi

callers(-4) is not defined
callers(-3) is not defined
callers(-2) is /request/support/callers_out_of_bounds1
callers(-1) is /request/callers_out_of_bounds
callers(0) is /request/support/callers_out_of_bounds1
callers(1) is /request/callers_out_of_bounds
callers(2) is not defined
callers(3) is not defined
callers(4) is not defined
EOF
                    );


#------------------------------------------------------------

    $group->add_test( name => 'call_self',
                      description => 'Test $m->call_self',
                      component => <<'EOF',
called
<%init>
my $out;
if ( $m->call_self( \$out, undef ) )
{
    $m->print($out);
    return;
}
</%init>
EOF
                      expect => <<'EOF',
called
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'call_self_retval',
                      description => 'Test that we can get return value of component via $m->call_self',
                      component => <<'EOF',
called
<%init>
my @return;
if ( $m->call_self( undef, \@return ) )
{
    $m->print( "0: $return[0]\n1: $return[1]\n" );
    return;
}
return ( 'foo', 'bar' );
</%init>
EOF
                      expect => <<'EOF',
0: foo
1: bar
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'call_self_output_and_retval',
                      description => 'Test that we can get return value and output of component via $m->call_self',
                      component => <<'EOF',
called
<%init>
my $out;
my @return;
if ( $m->call_self( \$out, \@return ) )
{
    $m->print( "${out}0: $return[0]\n1: $return[1]\n" );
    return;
}
</%init>
<%cleanup>
return ( 'foo', 'bar' );
</%cleanup>
EOF
                      expect => <<'EOF',
called
0: foo
1: bar
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'call_self_with_filter',
                      description => 'Test that $m->call_self works in presence of filter',
                      component => <<'EOF',
called
<%filter>
$_ = uc $_;
$_ .= ' filtered';
</%filter>
<%init>
my $out;
if ( $m->call_self( \$out, undef ) )
{
    $m->print($out);
    return;
}
</%init>
EOF
                      expect => <<'EOF',
CALLED
 filtered
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'subcomp_from_shared',
                      description => 'Test calling a subcomponent inside shared block',
                      component => <<'EOF',
<%shared>
$m->comp('subcomp');
</%shared>
<%def subcomp>
a subcomp
</%def>
EOF
                      expect_error =>
                      qr/cannot call a method or subcomponent from a <%shared> block/,
                    );

#------------------------------------------------------------

    $group->add_test( name => 'method_in_shared',
                      description => 'Test calling a method inside shared block',
                      component => <<'EOF',
<%shared>
$m->comp('SELF:meth');
</%shared>
<%method meth>
a method
</%method>
EOF
                      expect_error =>
                      qr/cannot call a method or subcomponent from a <%shared> block/,
                    );

#------------------------------------------------------------

    $group->add_test( name => 'notes',
                      description => 'Test the notes() method',
                      component => <<'EOF',
% $m->notes('key', 'value');
k: <% $m->notes('key') %>
k2: <% $m->notes->{key} %>
EOF
                      expect =>
                      qr/k: value\s+k2: value/,
                    );

#------------------------------------------------------------

    $group->add_test( name => 'flush_and_store',
                      description => q{Test that $m->flush_buffer is ignored in a store'd component},
                      interp_params => { autoflush => 1 },
                      component => <<'EOF',
<%def .world>\
World\
</%def>

% my $world;
% $m->comp( { store => \$world }, '.world');
Hello, <% $world %>!

% $world = $m->scomp('.world');
Hello, <% $world %>!
EOF
                      expect => <<'EOF',

Hello, World!

Hello, World!
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'flush_and_scomp_recursive',
                      description => 'Test that $m->flush_buffer is ignored in a recursive scomp() call',
                      interp_params => { autoflush => 1 },
                      component => <<'EOF',
<%def .orld>\
orld\
</%def>

<%def .world>\
W<& .orld &>\
</%def>

% my $world = $m->scomp('.world');
Hello, <% $world %>!
EOF
                      expect => <<'EOF',


Hello, World!
EOF
                    );

#------------------------------------------------------------

    return $group;
}