summaryrefslogtreecommitdiff
blob: 422cc851838f8cabbecb7b100eeb526576b16c43 (plain)
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
From e723aeecf60ece32f6a1381f5c026ae08cae9913 Mon Sep 17 00:00:00 2001
From: Kent Fredric <kentnl@gentoo.org>
Date: Sat, 13 Jan 2018 13:48:31 +1300
Subject: Fix tests warning w/ CGI.pm

This currently seems like an intractable problem with the syntax of
Template::Toolkit forcing list context by default on called functions.

The only real way around this is to either:

A) always use Template::Plugin::Scalar to enforce scalar context
B) abuse cgi.multi_param to simply silence the warning and being an
   adult about the fact "yes, this returns a list, make sure you do the
   right thing with that"

Bug: https://rt.cpan.org/Ticket/Display.html?id=100503
---
 t/cgi.t | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/t/cgi.t b/t/cgi.t
index 023ab5ab..6086e145 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -49,28 +49,32 @@ sub barf {
 
 __END__
 -- test --
+[% USE scalar -%]
 [% USE cgi = CGI('id=abw&name=Andy+Wardley'); global.cgi = cgi -%]
-name: [% global.cgi.param('name') %]
+name: [% global.cgi.scalar.param('name') %]
 -- expect --
 name: Andy Wardley
 
 -- test --
-name: [% global.cgi.param('name') %]
+[% USE scalar -%]
+name: [% global.cgi.scalar.param('name') %]
 
 -- expect --
 name: Andy Wardley
 
 -- test --
-[% FOREACH key = global.cgi.param.sort -%]
-   * [% key %] : [% global.cgi.param(key) %]
+[% USE scalar -%]
+[% FOREACH key = global.cgi.multi_param.sort -%]
+   * [% key %] : [% global.cgi.scalar.param(key) %]
 [% END %]
 -- expect --
    * id : abw
    * name : Andy Wardley
 
 -- test --
-[% FOREACH key = global.cgi.param().sort -%]
-   * [% key %] : [% global.cgi.param(key) %]
+[% USE scalar -%]
+[% FOREACH key = global.cgi.multi_param().sort -%]
+   * [% key %] : [% global.cgi.scalar.param(key) %]
 [% END %]
 -- expect --
    * id : abw
-- 
2.15.1