Skip to content

Commit

Permalink
better test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 14, 2011
1 parent fe74c1a commit 0a963ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions t/mojo/command.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use Mojo::Base -strict;

use Test::More tests => 23;
use Test::More tests => 27;

use Cwd 'cwd';
use File::Spec;
Expand All @@ -16,7 +16,7 @@ my $command = Mojo::Command->new;
isa_ok $command->app, 'Mojo', 'right application';

# UNIX DATA templates
my $unix = "@@ template1\nFirst Template\n@\@template2\r\nSecond Template\n";
my $unix = "@@ template1\nFirst Template\n@@ template2\r\nSecond Template\n";
open my $data, '<', \$unix;
no strict 'refs';
*{"Example::Package::UNIX::DATA"} = $data;
Expand All @@ -30,7 +30,7 @@ close $data;

# Windows DATA templates
my $windows =
"@@ template3\r\nThird Template\r\n@\@template4\r\nFourth Template\r\n";
"@@ template3\r\nThird Template\r\n@@ template4\r\nFourth Template\r\n";
open $data, '<', \$windows;
no strict 'refs';
*{"Example::Package::Windows::DATA"} = $data;
Expand All @@ -42,6 +42,21 @@ is_deeply [sort keys %{$command->get_all_data('Example::Package::Windows')}],
[qw/template3 template4/], 'right DATA files';
close $data;

# Mixed whitespace
my $mixed = "@\@template5\n5\n\n@@ template6\n6\n@@ template7\n7";
open $data, '<', \$mixed;
no strict 'refs';
*{"Example::Package::Mixed::DATA"} = $data;
is $command->get_data('template5', 'Example::Package::Mixed'), "5\n\n",
'right template';
is $command->get_data('template6', 'Example::Package::Mixed'), "6\n",
'right template';
is $command->get_data('template7', 'Example::Package::Mixed'), '7',
'right template';
is_deeply [sort keys %{$command->get_all_data('Example::Package::Mixed')}],
[qw/template5 template6 template7/], 'right DATA files';
close $data;

# Class to file
is $command->class_to_file('Foo::Bar'), 'foo_bar', 'right file';
is $command->class_to_file('FooBar'), 'foo_bar', 'right file';
Expand Down
2 changes: 1 addition & 1 deletion t/mojolicious/lite_app.t
Expand Up @@ -1957,7 +1957,7 @@ Not Bender!
@@ localized_partial.html.ep
<%= $test %>
@@layouts/localized1.html.ep
@@ layouts/localized1.html.ep
localized1 <%= content %>
@@ layouts/localized2.html.ep
Expand Down

0 comments on commit 0a963ee

Please sign in to comment.