Skip to content

Commit

Permalink
fixed a few more small test bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 23, 2011
1 parent 9d8c327 commit 3e4499b
Show file tree
Hide file tree
Showing 16 changed files with 331 additions and 328 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.

2.08 2011-10-23 00:00:00
- Fixed a few more small test bugs.

2.07 2011-10-23 00:00:00
- Improved documentation.
- Fixed a few small test bugs.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -860,7 +860,7 @@ You can also append a callback to perform requests non-blocking.
=head2 C<need_proxy>
my $need_proxy = $ua->need_proxy('intranet.mojolicio.us');
my $success = $ua->need_proxy('intranet.mojolicio.us');
Check if request for domain would use a proxy server.
Note that this method is EXPERIMENTAL and might change without warning!
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -35,7 +35,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Leaf Fluttering In Wind';
our $VERSION = '2.07';
our $VERSION = '2.08';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down
34 changes: 17 additions & 17 deletions t/mojo/bytestream.t
Expand Up @@ -390,20 +390,20 @@ $stream = Mojo::ByteStream->new(Mojo::ByteStream->new('test'));
ok !ref $stream->to_string, 'nested bytestream stringified';

# Secure compare
is b('hello')->secure_compare('hello'), 1, 'values are equal';
is b('hell')->secure_compare('hello'), undef, 'values are not equal';
is b('hallo')->secure_compare('hello'), undef, 'values are not equal';
is b('0')->secure_compare('0'), 1, 'values are equal';
is b('1')->secure_compare('1'), 1, 'values are equal';
is b('1')->secure_compare('0'), undef, 'values are not equal';
is b('0')->secure_compare('1'), undef, 'values are not equal';
is b('00')->secure_compare('00'), 1, 'values are equal';
is b('11')->secure_compare('11'), 1, 'values are equal';
is b('11')->secure_compare('00'), undef, 'values are not equal';
is b('00')->secure_compare('11'), undef, 'values are not equal';
is b('')->secure_compare(''), 1, 'values are equal';
is b('0♥')->secure_compare('0♥'), 1, 'values are equal';
is b('♥1')->secure_compare('♥1'), 1, 'values are equal';
is b('')->secure_compare('♥0'), undef, 'values are not equal';
is b('0♥')->secure_compare(''), undef, 'values are not equal';
is b('0♥1')->secure_compare('1♥0'), undef, 'values are not equal';
ok b('hello')->secure_compare('hello'), 'values are equal';
ok !b('hell')->secure_compare('hello'), 'values are not equal';
ok !b('hallo')->secure_compare('hello'), 'values are not equal';
ok b('0')->secure_compare('0'), 'values are equal';
ok b('1')->secure_compare('1'), 'values are equal';
ok !b('1')->secure_compare('0'), 'values are not equal';
ok !b('0')->secure_compare('1'), 'values are not equal';
ok b('00')->secure_compare('00'), 'values are equal';
ok b('11')->secure_compare('11'), 'values are equal';
ok !b('11')->secure_compare('00'), 'values are not equal';
ok !b('00')->secure_compare('11'), 'values are not equal';
ok b('')->secure_compare(''), 'values are equal';
ok b('0♥')->secure_compare('0♥'), 'values are equal';
ok b('♥1')->secure_compare('♥1'), 'values are equal';
ok !b('')->secure_compare('♥0'), 'values are not equal';
ok !b('0♥')->secure_compare(''), 'values are not equal';
ok !b('0♥1')->secure_compare('1♥0'), 'values are not equal';
4 changes: 2 additions & 2 deletions t/mojo/command.t
Expand Up @@ -93,7 +93,7 @@ my $cwd = cwd;
my $dir = File::Temp::tempdir(CLEANUP => 1);
chdir $dir;
$command->create_rel_dir('foo/bar');
is -d File::Spec->catdir($dir, qw/foo bar/), 1, 'directory exists';
ok -d File::Spec->catdir($dir, qw/foo bar/), 'directory exists';
my $template = "@@ foo_bar\njust <%= 'works' %>!\n";
open $data, '<', \$template;
no strict 'refs';
Expand All @@ -102,7 +102,7 @@ $command->render_to_rel_file('foo_bar', 'bar/baz.txt');
open my $txt, '<', $command->rel_file('bar/baz.txt');
is join('', <$txt>), "just works!\n", 'right result';
$command->chmod_rel_file('bar/baz.txt', 0700);
is -e $command->rel_file('bar/baz.txt'), 1, 'file is executable';
ok -e $command->rel_file('bar/baz.txt'), 'file is executable';
$command->write_rel_file('123.xml', "seems\nto\nwork");
open my $xml, '<', $command->rel_file('123.xml');
is join('', <$xml>), "seems\nto\nwork", 'right result';
Expand Down
30 changes: 15 additions & 15 deletions t/mojo/content.t
Expand Up @@ -11,24 +11,24 @@ use_ok 'Mojo::Content::Single';
# Single
my $content = Mojo::Content::Single->new;
$content->asset->add_chunk('foo');
is $content->body_contains('a'), undef, 'content does not contain "a"';
is $content->body_contains('f'), 1, 'content contains "f"';
is $content->body_contains('o'), 1, 'content contains "o"';
is $content->body_contains('foo'), 1, 'content contains "foo"';
ok !$content->body_contains('a'), 'content does not contain "a"';
ok $content->body_contains('f'), 'content contains "f"';
ok $content->body_contains('o'), 'content contains "o"';
ok $content->body_contains('foo'), 'content contains "foo"';

# Multipart
$content = Mojo::Content::MultiPart->new(parts => [$content]);
is $content->body_contains('a'), undef, 'content does not contain "a"';
is $content->body_contains('f'), 1, 'content contains "f"';
is $content->body_contains('o'), 1, 'content contains "o"';
is $content->body_contains('foo'), 1, 'content contains "foo"';
ok !$content->body_contains('a'), 'content does not contain "a"';
ok $content->body_contains('f'), 'content contains "f"';
ok $content->body_contains('o'), 'content contains "o"';
ok $content->body_contains('foo'), 'content contains "foo"';
push @{$content->parts}, Mojo::Content::Single->new;
$content->parts->[1]->asset->add_chunk('.*?foo+');
$content->parts->[1]->headers->header('X-Bender' => 'bar+');
is $content->body_contains('z'), undef, 'content does not contain "z"';
is $content->body_contains('f'), 1, 'content contains "f"';
is $content->body_contains('o'), 1, 'content contains "o"';
is $content->body_contains('foo'), 1, 'content contains "foo"';
is $content->body_contains('bar+'), 1, 'content contains "bar+"';
is $content->body_contains('.'), 1, 'content contains "."';
is $content->body_contains('.*?foo+'), 1, 'content contains ".*?foo+"';
ok !$content->body_contains('z'), 'content does not contain "z"';
ok $content->body_contains('f'), 'content contains "f"';
ok $content->body_contains('o'), 'content contains "o"';
ok $content->body_contains('foo'), 'content contains "foo"';
ok $content->body_contains('bar+'), 'content contains "bar+"';
ok $content->body_contains('.'), 'content contains "."';
ok $content->body_contains('.*?foo+'), 'content contains ".*?foo+"';
40 changes: 20 additions & 20 deletions t/mojo/hypnotoad.t
Expand Up @@ -64,32 +64,32 @@ my $ua = Mojo::UserAgent->new;
# Application is alive
my $tx = $ua->get("http://127.0.0.1:$port1/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, undef, 'connection was not kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok !$tx->kept_alive, 'connection was not kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello Hypnotoad!', 'right content';

# Application is alive (second port)
$tx = $ua->get("http://127.0.0.1:$port2/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, undef, 'connection was not kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok !$tx->kept_alive, 'connection was not kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello Hypnotoad!', 'right content';

# Same result
$tx = $ua->get("http://127.0.0.1:$port1/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, 1, 'connection was not kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok $tx->kept_alive, 'connection was not kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello Hypnotoad!', 'right content';

# Same result (second port)
$tx = $ua->get("http://127.0.0.1:$port2/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, 1, 'connection was not kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok $tx->kept_alive, 'connection was not kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello Hypnotoad!', 'right content';

Expand All @@ -108,16 +108,16 @@ open my $hot_deploy, '-|', $^X, "$prefix/hypnotoad", $script;
# Connection did not get lost
$tx = $ua->get("http://127.0.0.1:$port1/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, 1, 'connection was kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok $tx->kept_alive, 'connection was kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello Hypnotoad!', 'right content';

# Connection did not get lost (second port)
$tx = $ua->get("http://127.0.0.1:$port2/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, 1, 'connection was kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok $tx->kept_alive, 'connection was kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello Hypnotoad!', 'right content';

Expand All @@ -134,32 +134,32 @@ while (1) {
# Application has been reloaded
$tx = $ua->get("http://127.0.0.1:$port1/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, undef, 'connection was not kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok !$tx->kept_alive, 'connection was not kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello World!', 'right content';

# Application has been reloaded (second port)
$tx = $ua->get("http://127.0.0.1:$port2/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, undef, 'connection was not kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok !$tx->kept_alive, 'connection was not kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello World!', 'right content';

# Same result
$tx = $ua->get("http://127.0.0.1:$port1/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, 1, 'connection was kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok $tx->kept_alive, 'connection was kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello World!', 'right content';

# Same result (second port)
$tx = $ua->get("http://127.0.0.1:$port2/hello");
ok $tx->is_finished, 'transaction is finished';
is $tx->keep_alive, 1, 'connection will be kept alive';
is $tx->kept_alive, 1, 'connection was kept alive';
ok $tx->keep_alive, 'connection will be kept alive';
ok $tx->kept_alive, 'connection was kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello World!', 'right content';

Expand Down
44 changes: 22 additions & 22 deletions t/mojo/path.t
Expand Up @@ -136,29 +136,29 @@ is $path->trailing_slash, undef, 'no trailing slash';

# Contains
$path = Mojo::Path->new('/foo/bar');
is $path->contains('/'), 1, 'contains path';
is $path->contains('/foo'), 1, 'contains path';
is $path->contains('/foo/bar'), 1, 'contains path';
is $path->contains('/foobar'), undef, 'does not contain path';
is $path->contains('/foo/b'), undef, 'does not contain path';
is $path->contains('/foo/bar/baz'), undef, 'does not contain path';
ok $path->contains('/'), 'contains path';
ok $path->contains('/foo'), 'contains path';
ok $path->contains('/foo/bar'), 'contains path';
ok !$path->contains('/foobar'), 'does not contain path';
ok !$path->contains('/foo/b'), 'does not contain path';
ok !$path->contains('/foo/bar/baz'), 'does not contain path';
$path = Mojo::Path->new('/♥/bar');
is $path->contains('/♥'), 1, 'contains path';
is $path->contains('/♥/bar'), 1, 'contains path';
is $path->contains('/♥foo'), undef, 'does not contain path';
is $path->contains('/foo♥'), undef, 'does not contain path';
ok $path->contains('/♥'), 'contains path';
ok $path->contains('/♥/bar'), 'contains path';
ok !$path->contains('/♥foo'), 'does not contain path';
ok !$path->contains('/foo♥'), 'does not contain path';
$path = Mojo::Path->new('/');
is $path->contains('/'), 1, 'contains path';
is $path->contains('/foo'), undef, 'does not contain path';
ok $path->contains('/'), 'contains path';
ok !$path->contains('/foo'), 'does not contain path';
$path = Mojo::Path->new('/0');
is $path->contains('/'), 1, 'contains path';
is $path->contains('/0'), 1, 'contains path';
is $path->contains('/0/0'), undef, 'does not contain path';
ok $path->contains('/'), 'contains path';
ok $path->contains('/0'), 'contains path';
ok !$path->contains('/0/0'), 'does not contain path';
$path = Mojo::Path->new('/0/♥.html');
is $path->contains('/'), 1, 'contains path';
is $path->contains('/0'), 1, 'contains path';
is $path->contains('/0/♥.html'), 1, 'contains path';
is $path->contains('/0/♥'), undef, 'does not contain path';
is $path->contains('/0/0.html'), undef, 'does not contain path';
is $path->contains('/0.html'), undef, 'does not contain path';
is $path->contains('/♥.html'), undef, 'does not contain path';
ok $path->contains('/'), 'contains path';
ok $path->contains('/0'), 'contains path';
ok $path->contains('/0/♥.html'), 'contains path';
ok !$path->contains('/0/♥'), 'does not contain path';
ok !$path->contains('/0/0.html'), 'does not contain path';
ok !$path->contains('/0.html'), 'does not contain path';
ok !$path->contains('/♥.html'), 'does not contain path';

0 comments on commit 3e4499b

Please sign in to comment.