File Coverage

test/html/rawinput/include.htm
Criterion Covered Total %
statement 115 117 98.2
branch 3 4 75.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 122 125 97.6


line stmt bran cond sub pod time code
1 1     1   10  
  1         3  
  1         176  
2            
3            
4 2     2   5 Embperl Tests - Include other Embperl pages via Execute
  2         4  
5            
6 2         37  
7            

Embperl Tests - Include other Embperl pages via Execute

8              
9 2         6 [- $optRawInput = 1 -]
10 2         4  
  2         6  
11             [- $tst1 = '

Here is some text

' . "\n" ; -]
12 1     1   6  
  1     1   2  
  1         53  
  1         6  
  1         2  
  1         32  
  2         3  
  2         4  
13              
14 2         30

1.) Include from memory

15              
16 2         4 [- Execute ({input => \$tst1,
17 2         3 mtime => 1,
  2         16  
18             inputfile => 'Some text',
19             }) ;
20             -]
21              
22            

2.) Include from memory with some Embperl code

23 2         46  
24 2         4 [- Execute ({input => \('[- @ar = (a1, b2, c3) -' . ']
[+$ar[$col]+]

' . "\n" ),
25 2         5 mtime => 1,
  2         12  
26             inputfile => 'table',
27             }) ;
28             -]
29              
30            

3.) Include from memory with passing of variables

31 2         47  
32              
33 2         4 [- $MyPackage::Interface::Var = 'Some Var' ; -]
34 2         2  
  2         6  
35             [- Execute ({input => \"

Transfer some vars [+ \$Var +] !

\n" ,
36 2         3 inputfile => 'Var',
  2         11  
37             mtime => 1,
38             'package' => 'MyPackage::Interface',
39             }) ;
40             -]
41              
42            

4.) Change the variable, but not the code

43 2         542  
44 2         7 [-
45 2         3  
  2         5  
46             $MyPackage::Interface::Var = 'Do it again' ;
47              
48             # code is the same, so give the same mtime and inputfile to avoid recompile
49             # Note you get problems is you change the code, but did not restart the server or
50             # change the value in mtime. So make sure if you change something also change mtime!
51 2         364  
52             Execute ({input => \"

Transfer some vars [+ \$Var +] !

\n",
53             inputfile => 'Var2',
54             mtime => 1,
55             'package' => 'MyPackage::Interface',
56             req_rec => $req_rec}) ;
57             -]
58 2         48

5a.) Use method -> param to pass parameters

59              
60              
61 2         6 [-
62 2         5 Execute ({input => \"

Use method -> param to transfer some data ([+ do { \$p = shift -> component -> param -> param ; \"\@\$p\" } +]) !

\n",
  2         18  
63             inputfile => 'Parammethod',
64             param => [1, 2, 3, 4] }
65             ) ;
66             -]
67              
68 2         45

5.) Use \@param to pass parameters

69              
70              
71 2         4 [-
72 2         3 Execute ({input => \"

Use \@param to transfer some data ([+ \"\@param\" +]) !

\n",
  2         14  
73             inputfile => 'Param',
74             param => [1, 2, 3, 4] }
75             ) ;
76             -]
77              
78 2         50  
79            

6.) Use \@param to pass parameters and return it

80              
81 2         5 [- @p = ('vara', 'varb') ; -]
82 2         4  
  2         7  
83 2         13

$p[0] is [+ $p[0] +] and $p[1] is [+ $p[1] +]

84 2         35  
  2         7  
85 2         4 [-
86 2         5 Execute ({input => \('

Got data in @param ([+ "@param" +]) !

[- $param[0] = "newA" ; $param[1] = "newB" ; -' . ']

Change data in @param to ([+ "@param" +]) !

' . "\n"),
  2         13  
87             inputfile => 'Param & Return',
88             req_rec => $req_rec,
89             param => \@p }
90             ) ;
91             -]
92              
93 2         42

$p[0] is now [+ $p[0] +] and $p[1] is now [+ $p[1] +]

  2         11  
94 2         9  
95            

7.) Presetup \%fdat and \@ffld

96              
97 2         4 [-
98 2         4  
  2         9  
99             %myfdat = ('test' => 'value',
100             'fdat' => 'text') ;
101 2         17
102             @myffld = sort keys %myfdat ;
103 2         18  
104             Execute ({input => \('

[+ $ffld[$row] +][+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]

' . "\n") ,
105             inputfile => 'fdat & ffld',
106             req_rec => $req_rec,
107             fdat => \%myfdat,
108             ffld => \@myffld}
109             ) ;
110              
111             -]
112 2         46  
113              
114            

7a.) Presetup my \%fdat and my \@ffld

115              
116 2         5 [-
117 2         4  
  2         10  
118             my %myfdat = ('test1' => 'value1',
119             'fdat1' => 'text1') ;
120 2         12
121             my @myffld = sort keys %myfdat ;
122 2         16  
123             Execute ({input => \('

[+ $ffld[$row] +][+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]

' . "\n") ,
124             inputfile => 'fdat & ffld',
125             req_rec => $req_rec,
126             fdat => \%myfdat,
127             ffld => \@myffld}
128             ) ;
129              
130             -]
131 2         42  
132            

7b.) Presetup \%fdat

133              
134 2         3 [-
135 2         3 %myfdat = ('test2' => 'value2',
  2         10  
136             'fdat2' => 'text2') ;
137            
138             #@myffld = sort keys %myfdat ;
139 2         13 Execute ({input => \('

[+ $ffld[$row] +][+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]

' . "\n") ,
140             inputfile => 'fdat & ffld',
141             req_rec => $req_rec,
142             fdat => \%myfdat,}
143             ) ;
144              
145             -]
146              
147 2         40  
148            

7c.) Presetup \@ffld

149              
150 2         5 [-
151 2         5 %myfdat = ('test3' => 'value3',
  2         9  
152             'fdat3' => 'text3') ;
153            
154 2         11 @myffld = sort keys %myfdat ;
155 2         13 Execute ({input => \('

[+ $ffld[$row] +][+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]

@ffld = [+ "@ffld" +]' . "\n") ,
156             inputfile => 'ffld',
157             req_rec => $req_rec,
158             ffld => \@myffld}
159             ) ;
160              
161             -]
162              
163 2         51  
164            

8a.) Include a file

165              
166 2         5 [- Execute ({inputfile => '../inc.htm', options => 0, input_escmode => 7, }) -]
167 2         3  
  2         14  
168            

8b.) Include again the same file

169 2         54  
170 2         5 [- Execute ({inputfile => '../inc.htm', options => 0, input_escmode => 7, }) -]
171 2         4  
  2         12  
172            

9.) Include a file and return output in a scalar

173 2         40  
174              
175              
176 2         5 [- Execute ({inputfile => '../inc.htm',
177 2         3 output => \$out,
  2         16  
178             options => 0, input_escmode => 7,
179             req_rec => $req_rec}) ;
180             -]
181              
182 2         34

[+ $out +]

183 2         37  
184              
185            

10.) Include inside a table

186              
187 2         4 [- @a = ('m1', 'm2', 'm3') -]
188 2         3  
  2         5  
189 2         10
190 2         30
  8         255  
191 8         114
192 8 100       51 [+ $a[$row] +] : [- Execute ({inputfile => '../incsub.htm', req_rec => $req_rec, param => [$a[$row], 'main']}) -]
  2         92  
  2         4  
193 6 50       11
  6         7  
194 6         33
195 0         0
  0         0  
196 6         122  
197 6         99  
198            

11.) Include a file with parameters

199 2         28  
200 2         3 [- Execute ('../incparam.htm', 0, 'B', 'three', 'dddd', '555') -]
201 2         4  
  2         9  
202            

12.) Include a file and write outputfile

203 2         65  
204             [# - Execute ({inputfile => '../inc.htm',
205 2         4 outputfile => "../../tmp/incout.htm",
206             }) ;
207 2         23161 - #]
208              
209            

12.) Done :-)

210              
211            
212              
213              
214            


215              
216             Embperl (c) 1997-2005 G.Richter
217              
218            
219