1use strict;
2use warnings;
3use Test::More;
4use Plack::Response;
5
6sub res {
7    my $res = Plack::Response->new;
8    my %v = @_;
9    while (my($k, $v) = each %v) {
10        $res->$k($v);
11    }
12    $res->finalize;
13}
14
15is_deeply(
16    res(
17        status => 200,
18        body => 'hello',
19    ),
20    [ 200, +[], [ 'hello' ] ]
21);
22
23my $res = res(
24    status => 200,
25    cookies => +{
26        'foo_sid' => +{
27            value => 'ASDFJKL:',
28            expires => 'Thu, 25-Apr-1999 00:40:33 GMT',
29            domain  => 'example.com',
30            path => '/',
31        },
32        'poo_sid' => +{
33            value => 'QWERTYUI',
34            expires => 'Thu, 25-Apr-1999 00:40:33 GMT',
35            domain  => 'example.com',
36            path => '/',
37        },
38    },
39    body => 'hello',
40);
41
42is($res->[0], 200);
43
44is(scalar(@{ $res->[1] }), 4);
45is($res->[1][0], 'Set-Cookie');
46is($res->[1][2], 'Set-Cookie');
47my @cookies = sort($res->[1][1], $res->[1][3]);
48is($cookies[0], 'foo_sid=ASDFJKL%3A; domain=example.com; path=/; expires=Thu, 25-Apr-1999 00:40:33 GMT');
49is($cookies[1], 'poo_sid=QWERTYUI; domain=example.com; path=/; expires=Thu, 25-Apr-1999 00:40:33 GMT');
50
51is(scalar(@{ $res->[2] }), 1);
52is($res->[2][0], 'hello');
53
54done_testing;
55