Skip to content
This repository
Browse code

unuse Test::Base

  • Loading branch information...
commit 2e332e2b55acdf933b238bd77d1cfe8ffca7d64b 1 parent 01d6453
Tatsuhiko Miyagawa authored January 30, 2010
5  Makefile.PL
@@ -24,9 +24,7 @@ requires 'Filesys::Notify::Simple'; # plackup -r
24 24
 requires 'Hash::MultiValue', 0.05; # Plack::Request
25 25
 requires 'HTTP::Body'; # Plack::Request
26 26
 
27  
-# TODO: they can go away once we create Plack-Middlewares dist
28  
-# Middleware::Static and App::File
29  
-requires 'Path::Class';
  27
+requires 'Path::Class'; # App::File
30 28
 
31 29
 build_requires 'Test::More', 0.88;
32 30
 build_requires 'Test::TCP', 0.11;
@@ -38,7 +36,6 @@ author_tests 'xt';
38 36
 install_share 'share';
39 37
 install_script 'scripts/plackup';
40 38
 
41  
-use_test_base;
42 39
 auto_include;
43 40
 auto_install;
44 41
 auto_set_repository;
138  t/Plack-Middleware/conditionalget.t
... ...
@@ -1,97 +1,61 @@
1 1
 use strict;
2 2
 use warnings;
3  
-use Test::Base;
4 3
 use Plack::Builder;
5  
-
6  
-filters {
7  
-    app => 'eval',
8  
-    env => 'yaml',
9  
-    headers => 'yaml',
10  
-};
11  
-
12  
-plan tests => 2 * blocks;
13  
-
14  
-run {
15  
-    my $block = shift;
  4
+use Test::More;
  5
+
  6
+my @tests = (
  7
+    {
  8
+        app => sub { [ 200, [ 'Content-Type' => 'text/plain' ], [ 'OK' ] ] },
  9
+        env => { REQUEST_METHOD => 'GET' },
  10
+        status => 200,
  11
+        headers => [ 'Content-Type', 'text/plain' ],
  12
+    },
  13
+    {
  14
+        app => sub { [ 200, [ 'ETag' => 'Foo', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] },
  15
+        env => { REQUEST_METHOD => "GET", HTTP_IF_NONE_MATCH => "Foo" },
  16
+        status => 304,
  17
+        headers => [ ETag => 'Foo' ],
  18
+    },
  19
+    {
  20
+        app => sub { [ 200, [ 'Last-Modified' => 'Wed, 23 Sep 2009 13:36:33 GMT', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] },
  21
+        env => { REQUEST_METHOD => "GET", HTTP_IF_MODIFIED_SINCE => "Wed, 23 Sep 2009 13:36:33 GMT" },
  22
+        status => 304,
  23
+        headers => [ "Last-Modified" => "Wed, 23 Sep 2009 13:36:33 GMT" ],
  24
+    },
  25
+    {
  26
+        app => sub { [ 200, [ 'Last-Modified' => 'Wed, 23 Sep 2009 13:36:33 GMT', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] },
  27
+        env => { REQUEST_METHOD => "GET", HTTP_IF_MODIFIED_SINCE => "Wed, 23 Sep 2009 13:36:32 GMT" },
  28
+        status => 200,
  29
+        headers => [
  30
+            "Last-Modified", "Wed, 23 Sep 2009 13:36:33 GMT", "Content-Type", "text/plain",
  31
+        ],
  32
+    },
  33
+    {
  34
+        app => sub { [ 200, [ 'Last-Modified' => 'Wed, 23 Sep 2009 13:36:33 GMT', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] },
  35
+        env => { REQUEST_METHOD => "GET", HTTP_IF_MODIFIED_SINCE => "Wed, 23 Sep 2009 13:36:33 GMT; length=2" },
  36
+        status => 304,
  37
+        headers => [ "Last-Modified", "Wed, 23 Sep 2009 13:36:33 GMT" ],
  38
+    },
  39
+    {
  40
+        app => sub { [ 200, [ 'ETag' => 'Foo', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] },
  41
+        env => { REQUEST_METHOD => "POST", HTTP_IF_NONE_MATCH => "Foo" },
  42
+        status => 200,
  43
+        headers => [ ETag => "Foo", "Content-Type" => "text/plain" ],
  44
+    }
  45
+);
  46
+
  47
+plan tests => 2*@tests;
  48
+
  49
+for my $block (@tests) {
16 50
     my $handler = builder {
17 51
         enable "Plack::Middleware::ConditionalGET";
18  
-        $block->app;
  52
+        $block->{app};
19 53
     };
20  
-    my $res = $handler->($block->env);
21  
-    is $res->[0], $block->status;
22  
-    is_deeply $res->[1], $block->headers;
23  
-};
24  
-
25  
-__END__
26  
-
27  
-=== 200 response
28  
---- app
29  
-sub { [ 200, [ 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }
30  
---- env
31  
-REQUEST_METHOD: GET
32  
---- status: 200
33  
---- headers
34  
-- Content-Type
35  
-- text/plain
36  
-
37  
-=== ETag match
38  
---- app
39  
-sub { [ 200, [ 'ETag' => 'Foo', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }
40  
---- env
41  
-REQUEST_METHOD: GET
42  
-HTTP_IF_NONE_MATCH: Foo
43  
---- status: 304
44  
---- headers
45  
-- ETag
46  
-- Foo
47  
-
48  
-=== If-Modified-Since match
49  
---- app
50  
-sub { [ 200, [ 'Last-Modified' => 'Wed, 23 Sep 2009 13:36:33 GMT', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }
51  
---- env
52  
-REQUEST_METHOD: GET
53  
-HTTP_IF_MODIFIED_SINCE: Wed, 23 Sep 2009 13:36:33 GMT
54  
---- status: 304
55  
---- headers
56  
-- Last-Modified
57  
-- Wed, 23 Sep 2009 13:36:33 GMT
58  
-
59  
-=== If-Modified-Since mismatch
60  
---- app
61  
-sub { [ 200, [ 'Last-Modified' => 'Wed, 23 Sep 2009 13:36:33 GMT', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }
62  
---- env
63  
-REQUEST_METHOD: GET
64  
-HTTP_IF_MODIFIED_SINCE: Wed, 23 Sep 2009 13:36:32 GMT
65  
---- status: 200
66  
---- headers
67  
-- Last-Modified
68  
-- Wed, 23 Sep 2009 13:36:33 GMT
69  
-- Content-Type
70  
-- text/plain
71  
-
72  
-=== If-Modified-Since match ie bug
73  
---- app
74  
-sub { [ 200, [ 'Last-Modified' => 'Wed, 23 Sep 2009 13:36:33 GMT', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }
75  
---- env
76  
-REQUEST_METHOD: GET
77  
-HTTP_IF_MODIFIED_SINCE: Wed, 23 Sep 2009 13:36:33 GMT; length=2
78  
---- status: 304
79  
---- headers
80  
-- Last-Modified
81  
-- Wed, 23 Sep 2009 13:36:33 GMT
  54
+    my $res = $handler->($block->{env});
  55
+    is $res->[0], $block->{status};
  56
+    is_deeply $res->[1], $block->{headers};
  57
+}
82 58
 
83  
-=== non-GET reqs
84  
---- app
85  
-sub { [ 200, [ 'ETag' => 'Foo', 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }
86  
---- env
87  
-REQUEST_METHOD: POST
88  
-HTTP_IF_NONE_MATCH: Foo
89  
---- status: 200
90  
---- headers
91  
-- ETag
92  
-- Foo
93  
-- Content-Type
94  
-- text/plain
95 59
 
96 60
 
97 61
 
124  t/Plack-Middleware/content_length.t
... ...
@@ -1,85 +1,53 @@
1 1
 use strict;
2  
-use Test::Base;
  2
+use Test::More;
3 3
 use Plack::Builder;
4 4
 
5  
-filters {
6  
-    app => 'eval',
7  
-    env => 'yaml',
8  
-    headers => 'yaml',
9  
-};
10  
-
11  
-plan tests => 1 * blocks;
12  
-
13  
-run {
14  
-    my $block = shift;
  5
+my @tests = (
  6
+    {
  7
+        app => sub { [ 200, [ 'Content-Type' => 'text/plain' ], [ 'OK' ] ] },
  8
+        env => { REQUEST_METHOD => 'GET' },
  9
+        headers=> [ 'Content-Type' => 'text/plain', 'Content-Length' => 2 ],
  10
+    },
  11
+    {
  12
+        app => sub {
  13
+            open my $fh, "<", "share/kyoto.jpg";
  14
+            [ 200, [ 'Content-Type' => 'image/jpeg' ], $fh ];
  15
+        },
  16
+        env => { REQUEST_METHOD => 'GET' },
  17
+        headers => [ 'Content-Type' => 'image/jpeg', 'Content-Length' => 2397701 ],
  18
+    },
  19
+    {
  20
+        app => sub {
  21
+            [ 304, [ ETag => 'Foo' ], [] ];
  22
+        },
  23
+        env => { REQUEST_METHOD => 'GET' },
  24
+        headers => [ ETag => 'Foo' ],
  25
+    },
  26
+    {
  27
+        app => sub {
  28
+            my $body = "Hello World";
  29
+            open my $fh, "<", \$body;
  30
+            [ 200, [ 'Content-Type' => 'text/plain' ], $fh ];
  31
+        },
  32
+        env => { REQUEST_METHOD => 'GET' },
  33
+        headers => [ 'Content-Type' => 'text/plain' ],
  34
+    },
  35
+    {
  36
+        app => sub {
  37
+            [ 200, [ 'Content-Type' => 'text/plain', 'Content-Length' => 11 ], [ "Hello World" ] ];
  38
+        },
  39
+        env => { REQUEST_METHOD => 'GET' },
  40
+        headers => [ 'Content-Type' => 'text/plain', 'Content-Length', 11 ],
  41
+    },
  42
+);
  43
+
  44
+plan tests => 1 * @tests;
  45
+
  46
+for my $block (@tests) {
15 47
     my $handler = builder {
16 48
         enable "Plack::Middleware::ContentLength";
17  
-        $block->app;
  49
+        $block->{app};
18 50
     };
19  
-    my $res = $handler->($block->env);
20  
-    is_deeply $res->[1], $block->headers;
  51
+    my $res = $handler->($block->{env});
  52
+    is_deeply $res->[1], $block->{headers};
21 53
 };
22  
-
23  
-__END__
24  
-
25  
-=== 200 response
26  
---- app
27  
-sub { [ 200, [ 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }
28  
---- env
29  
-REQUEST_METHOD: GET
30  
---- headers
31  
-- Content-Type
32  
-- text/plain
33  
-- Content-Length
34  
-- 2
35  
-
36  
-=== 200 response with filehandle
37  
---- app
38  
-sub {
39  
-    open my $fh, "<", "share/kyoto.jpg";
40  
-    [ 200, [ 'Content-Type' => 'image/jpeg' ], $fh ];
41  
-}
42  
---- env
43  
-REQUEST_METHOD: GET
44  
---- headers
45  
-- Content-Type
46  
-- image/jpeg
47  
-- Content-Length
48  
-- 2397701
49  
-
50  
-=== 304 no entity header
51  
---- app
52  
-sub {
53  
-    [ 304, [ ETag => 'Foo' ], [] ];
54  
-}
55  
---- env
56  
-REQUEST_METHOD: GET
57  
---- headers
58  
-- ETag
59  
-- Foo
60  
-
61  
-=== 200 not calculatable
62  
---- app
63  
-sub {
64  
-    my $body = "Hello World";
65  
-    open my $fh, "<", \$body;
66  
-    [ 200, [ 'Content-Type' => 'text/plain' ], $fh ];
67  
-}
68  
---- env
69  
-REQUEST_METHOD: GET
70  
---- headers
71  
-- Content-Type
72  
-- text/plain
73  
-
74  
-=== 200 with C-L
75  
---- app
76  
-sub {
77  
-    [ 200, [ 'Content-Type' => 'text/plain', 'Content-Length' => 11 ], [ "Hello World" ] ];
78  
-}
79  
---- env
80  
-REQUEST_METHOD: GET
81  
---- headers
82  
-- Content-Type
83  
-- text/plain
84  
-- Content-Length
85  
-- 11
82  t/Plack-Middleware/writer.t
... ...
@@ -1,58 +1,42 @@
1 1
 use strict;
2  
-use Test::Base;
  2
+use Test::More;
3 3
 use Plack::Builder;
4 4
 
5  
-filters {
6  
-    app => 'eval',
7  
-    env => 'yaml',
8  
-    headers => 'yaml',
9  
-};
  5
+my @tests = (
  6
+    {
  7
+        app => sub {
  8
+            return sub {
  9
+                $_[0]->([ 200, [ 'Content-Type' => 'text/plain' ], [ 'OK' ] ]);
  10
+            },
  11
+        },
  12
+        env => { REQUEST_METHOD => 'GET' },
  13
+        headers => [ 'Content-Type' => 'text/plain' ],
  14
+        body => 'OK',
  15
+    },
  16
+    {
  17
+        app => sub {
  18
+            return sub {
  19
+                my $writer = $_[0]->([ 200, [ 'Content-Type' => 'text/plain' ]]);
  20
+                $writer->write("O");
  21
+                $writer->write("K");
  22
+                $writer->close();
  23
+            },
  24
+        },
  25
+        env => { REQUEST_METHOD => 'GET' },
  26
+        headers => [ 'Content-Type', 'text/plain' ],
  27
+        body => 'OK',
  28
+    },
  29
+);
  30
+
10 31
 
11  
-plan tests => 2 * blocks;
  32
+plan tests => 2 * @tests;
12 33
 
13  
-run {
14  
-    my $block = shift;
  34
+for my $block (@tests) {
15 35
     my $handler = builder {
16 36
         enable "Plack::Middleware::Writer";
17  
-        $block->app;
  37
+        $block->{app};
18 38
     };
19  
-    my $res = $handler->($block->env);
20  
-    is_deeply $res->[1], $block->headers, "headers passed through";
21  
-    is join("", @{ $res->[2] }) . "\n", $block->body, "body accumulated";
  39
+    my $res = $handler->($block->{env});
  40
+    is_deeply $res->[1], $block->{headers}, "headers passed through";
  41
+    is join("", @{ $res->[2] }), $block->{body}, "body accumulated";
22 42
 };
23  
-
24  
-__END__
25  
-
26  
-=== simple write
27  
---- app
28  
-sub {
29  
-    return sub {
30  
-        $_[0]->([ 200, [ 'Content-Type' => 'text/plain' ], [ 'OK' ] ]);
31  
-    }
32  
-}
33  
---- env
34  
-REQUEST_METHOD: GET
35  
---- headers
36  
-- Content-Type
37  
-- text/plain
38  
---- body
39  
-OK
40  
-
41  
-=== iterative write
42  
---- app
43  
-sub {
44  
-    return sub {
45  
-        my $writer = $_[0]->([ 200, [ 'Content-Type' => 'text/plain' ]]);
46  
-
47  
-        $writer->write("O");
48  
-        $writer->write("K");
49  
-        $writer->close();
50  
-    }
51  
-}
52  
---- env
53  
-REQUEST_METHOD: GET
54  
---- headers
55  
-- Content-Type
56  
-- text/plain
57  
---- body
58  
-OK
105  t/Plack-Request/base.t
... ...
@@ -1,71 +1,54 @@
1 1
 use strict;
2 2
 use warnings;
3  
-use Test::Base;
4 3
 use Plack::Request;
5  
-
6  
-plan tests => 1*blocks;
7  
-
8  
-run {
9  
-    my $block = shift;
  4
+use Test::More;
  5
+
  6
+my @tests = (
  7
+  { host => 'localhost',
  8
+    base => 'http://localhost/' },
  9
+  { script_name => '/foo',
  10
+    host => 'localhost',
  11
+    base => 'http://localhost/foo' },
  12
+  { script_name => '/foo bar',
  13
+    host => 'localhost',
  14
+    base => 'http://localhost/foo%20bar' },
  15
+  { scheme => 'http',
  16
+    host => 'localhost:91',
  17
+    base => 'http://localhost:91/' },
  18
+  { scheme => 'http',
  19
+    host => 'example.com',
  20
+    base => 'http://example.com/' },
  21
+  { scheme => 'https',
  22
+    host => 'example.com',
  23
+    base => 'https://example.com/' },
  24
+  { scheme => 'http',
  25
+    server_name => 'example.com',
  26
+    server_port => 80,
  27
+    base => 'http://example.com/' },
  28
+  { scheme => 'http',
  29
+    server_name => 'example.com',
  30
+    server_port => 8080,
  31
+    base => 'http://example.com:8080/' },
  32
+  { host => 'foobar.com',
  33
+    server_name => 'example.com',
  34
+    server_port => 8080,
  35
+    base => 'http://foobar.com/' },
  36
+);
  37
+
  38
+plan tests => 1*@tests;
  39
+
  40
+for my $block (@tests) {
10 41
     my $env = {
11  
-        'psgi.url_scheme' => $block->scheme || 'http',
12  
-        HTTP_HOST => $block->host || undef,
13  
-        SERVER_NAME => $block->server_name || undef,
14  
-        SERVER_PORT => $block->server_port || undef,
15  
-        SCRIPT_NAME => $block->script_name || '',
  42
+        'psgi.url_scheme' => $block->{scheme} || 'http',
  43
+        HTTP_HOST => $block->{host} || undef,
  44
+        SERVER_NAME => $block->{server_name} || undef,
  45
+        SERVER_PORT => $block->{server_port} || undef,
  46
+        SCRIPT_NAME => $block->{script_name} || '',
16 47
     };
17 48
 
18 49
     my $req = Plack::Request->new($env);
19  
-    is $req->base, $block->base;
20  
-};
21  
-
22  
-__END__
23  
-
24  
-===
25  
---- script_name:
26  
---- host: localhost
27  
---- base: http://localhost/
28  
-
29  
-===
30  
---- script_name: /foo
31  
---- host: localhost
32  
---- base: http://localhost/foo
33  
-
34  
-===
35  
---- script_name: /foo bar
36  
---- host: localhost
37  
---- base: http://localhost/foo%20bar
38  
-
39  
-===
40  
---- scheme: http
41  
---- host: localhost:91
42  
---- base: http://localhost:91/
43  
-
44  
-===
45  
---- scheme: http
46  
---- host: example.com
47  
---- base: http://example.com/
48  
-
49  
-===
50  
---- scheme: https
51  
---- host: example.com
52  
---- base: https://example.com/
53  
-
54  
-===
55  
---- scheme: http
56  
---- server_name: example.com
57  
---- server_port: 80
58  
---- base: http://example.com/
  50
+    is $req->base, $block->{base};
  51
+}
59 52
 
60  
-===
61  
---- scheme: http
62  
---- server_name: example.com
63  
---- server_port: 8080
64  
---- base: http://example.com:8080/
65 53
 
66  
-===
67  
---- host: foobar.com
68  
---- server_name: example.com
69  
---- server_port: 8080
70  
---- base: http://foobar.com/
71 54
 
178  t/Plack-Request/uri.t
... ...
@@ -1,108 +1,88 @@
1 1
 use strict;
2 2
 use warnings;
3  
-use Test::Base;
  3
+use Test::More;
4 4
 use Plack::Request;
5 5
 
6  
-plan tests => 2*blocks;
7  
-
8  
-filters {
9  
-    add_env    => ['yaml'],
10  
-    parameters => ['eval'],
11  
-};
12  
-
13  
-run {
14  
-    my $block = shift;
  6
+my @tests = (
  7
+    { add_env => {
  8
+        HTTP_HOST => 'example.com',
  9
+        SCRIPT_NAME => "",
  10
+      },
  11
+      uri => 'http://example.com/',
  12
+      parameters => {} },
  13
+    { add_env => {
  14
+        HTTP_HOST => 'example.com',
  15
+        SCRIPT_NAME => "",
  16
+        PATH_INFO => "/foo bar",
  17
+      },
  18
+      uri => 'http://example.com/foo%20bar',
  19
+      parameters => {} },
  20
+    { add_env => {
  21
+        HTTP_HOST => 'example.com',
  22
+        SCRIPT_NAME => '/test.c',
  23
+      },
  24
+      uri => 'http://example.com/test.c',
  25
+      parameters => {} },
  26
+    { add_env => {
  27
+        HTTP_HOST => 'example.com',
  28
+        SCRIPT_NAME => '/test.c',
  29
+        PATH_INFO => '/info',
  30
+      },
  31
+      uri => 'http://example.com/test.c/info',
  32
+      parameters => {} },
  33
+    { add_env => {
  34
+        HTTP_HOST => 'example.com',
  35
+        SCRIPT_NAME => '/test',
  36
+        QUERY_STRING => 'dynamic=daikuma',
  37
+      },
  38
+      uri => 'http://example.com/test?dynamic=daikuma',
  39
+      parameters => { dynamic => 'daikuma' } },
  40
+    { add_env => {
  41
+        HTTP_HOST => 'example.com',
  42
+        SCRIPT_NAME => '/exec/'
  43
+      },
  44
+      uri => 'http://example.com/exec/',
  45
+      parameters => {} },
  46
+    { add_env => {
  47
+        SERVER_NAME => 'example.com'
  48
+      },
  49
+      uri => 'http://example.com/',
  50
+      parameters => {} },
  51
+    { add_env => {},
  52
+      uri => 'http:///',
  53
+      parameters => {} },
  54
+    { add_env => {
  55
+        HTTP_HOST => 'example.com',
  56
+        SCRIPT_NAME => "",
  57
+        QUERY_STRING => 'aco=tie'
  58
+      },
  59
+      uri => 'http://example.com/?aco=tie',
  60
+      parameters => { aco => 'tie' } },
  61
+    { add_env => {
  62
+        HTTP_HOST => 'example.com',
  63
+        SCRIPT_NAME => "",
  64
+        QUERY_STRING => 0
  65
+      },
  66
+      uri => 'http://example.com/?0',
  67
+      parameters => {} },
  68
+    { add_env => {
  69
+        HTTP_HOST => 'example.com',
  70
+        SCRIPT_NAME => "/foo bar",
  71
+        PATH_INFO => "/baz quux",
  72
+      },
  73
+      uri => 'http://example.com/foo%20bar/baz%20quux',
  74
+      parameters => {} }
  75
+);
  76
+
  77
+plan tests => 2 * @tests;
  78
+
  79
+for my $block (@tests) {
15 80
     my $env = {SERVER_PORT => 80};
16  
-    if ($block->add_env && ref($block->add_env) eq 'HASH') {
17  
-        while (my($key, $val) = each %{ $block->add_env }) {
18  
-            $env->{$key} = $val;
19  
-        }
  81
+    while (my($key, $val) = each %{ $block->{add_env} || {} }) {
  82
+        $env->{$key} = $val;
20 83
     }
21 84
     my $req = Plack::Request->new($env);
22 85
 
23  
-    is $req->uri, $block->uri;
24  
-    is_deeply $req->query_parameters, $block->parameters;
  86
+    is $req->uri, $block->{uri};
  87
+    is_deeply $req->query_parameters, $block->{parameters};
25 88
 };
26  
-
27  
-__END__
28  
-
29  
-===
30  
---- add_env
31  
-  HTTP_HOST: example.com
32  
-  SCRIPT_NAME: ""
33  
---- uri: http://example.com/
34  
---- parameters: {}
35  
-
36  
-===
37  
---- add_env
38  
-  HTTP_HOST: example.com
39  
-  SCRIPT_NAME: ""
40  
-  PATH_INFO: "/foo bar"
41  
---- uri: http://example.com/foo%20bar
42  
---- parameters: {}
43  
-
44  
-===
45  
---- add_env
46  
-  HTTP_HOST: example.com
47  
-  SCRIPT_NAME: /test.c
48  
---- uri: http://example.com/test.c
49  
---- parameters: {}
50  
-
51  
-===
52  
---- add_env
53  
-  HTTP_HOST: example.com
54  
-  SCRIPT_NAME: /test.c
55  
-  PATH_INFO: /info
56  
---- uri: http://example.com/test.c/info
57  
---- parameters: {}
58  
-
59  
-===
60  
---- add_env
61  
-  HTTP_HOST: example.com
62  
-  SCRIPT_NAME: /test
63  
-  QUERY_STRING: dynamic=daikuma
64  
---- uri: http://example.com/test?dynamic=daikuma
65  
---- parameters: { dynamic => 'daikuma' }
66  
-
67  
-
68  
-===
69  
---- add_env
70  
-  HTTP_HOST: example.com
71  
-  SCRIPT_NAME: /exec/
72  
---- uri: http://example.com/exec/
73  
---- parameters: {}
74  
-
75  
-===
76  
---- add_env
77  
-  SERVER_NAME: example.com
78  
---- uri: http://example.com/
79  
---- parameters: {}
80  
-
81  
-===
82  
---- add_env
83  
---- uri: http:///
84  
---- parameters: {}
85  
-
86  
-===
87  
---- add_env
88  
-  HTTP_HOST: example.com
89  
-  SCRIPT_NAME: ""
90  
-  QUERY_STRING: aco=tie
91  
---- uri: http://example.com/?aco=tie
92  
---- parameters: { aco => 'tie' }
93  
-
94  
-===
95  
---- add_env
96  
-  HTTP_HOST: example.com
97  
-  SCRIPT_NAME: ""
98  
-  QUERY_STRING: 0
99  
---- uri: http://example.com/?0
100  
---- parameters: {}
101  
-
102  
-===
103  
---- add_env
104  
-  HTTP_HOST: example.com
105  
-  SCRIPT_NAME: "/foo bar"
106  
-  PATH_INFO: "/baz quux"
107  
---- uri: http://example.com/foo%20bar/baz%20quux
108  
---- parameters: {}
47  t/Plack-Util/is_real_fh.t
... ...
@@ -1,37 +1,22 @@
1  
-use Test::Base;
  1
+use strict;
  2
+use Test::More;
2 3
 use Plack::Util;
3 4
 
4  
-plan tests => 2 * blocks;
  5
+{
  6
+    open my $fh, "<", "/dev/null";
  7
+    ok Plack::Util::is_real_fh($fh);
  8
+}
5 9
 
6  
-run {
7  
-    my $block = shift;
8  
-    my $res = Plack::Util::is_real_fh(eval $block->input);
  10
+{
  11
+    open my $fh, "<", \"foo";
  12
+    ok ! Plack::Util::is_real_fh($fh);
  13
+}
9 14
 
10  
-    ok !$@;
11  
-    ok $res == $block->ret;
12  
-};
13  
-
14  
-
15  
-__END__
16  
-
17  
-===
18  
---- input
19  
-open my $fh, "<", "/dev/null";
20  
-$fh;
21  
---- ret
22  
-1
23  
-
24  
-===
25  
---- input
26  
-open my $fh, "<", \"foo"; $fh
27  
---- ret
28  
-0
29  
-
30  
-===
31  
---- input
32  
-use IO::File;
33  
-IO::File->new("/dev/null");
34  
---- ret
35  
-1
  15
+{
  16
+    use IO::File;
  17
+    my $fh = IO::File->new("/dev/null");
  18
+    ok Plack::Util::is_real_fh($fh);
  19
+}
36 20
 
  21
+done_testing;
37 22
 

0 notes on commit 2e332e2

Please sign in to comment.
Something went wrong with that request. Please try again.