Skip to content

Instantly share code, notes, and snippets.

@unera
Created September 14, 2016 12:30
Show Gist options
  • Save unera/1ea008a89c4eddabdf65d7fc9affe163 to your computer and use it in GitHub Desktop.
Save unera/1ea008a89c4eddabdf65d7fc9affe163 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use warnings;
use strict;
use utf8;
use open qw(:std :utf8);
use Test::More tests => 6;
BEGIN {
require_ok 'Mojolicious';
use_ok 'Test::Mojo';
}
{
package TstApp;
use Mojo::Base 'Mojolicious';
sub startup {
my ($self) = @_;
$self->routes
-> get('/ping')
-> to(cb => sub { return shift->render(text => 'pong') })
-> name('ping');
}
}
package main;
my $t = Test::Mojo->new('TstApp');
note 'тесты mojo';
$t -> get_ok('/ping')
-> status_is(200)
-> content_is('pong', 'Запрос выполнен успешно');
note 'другие тесты';
my $str_from_somewhere = 'Привет, медвед';
like $str_from_somewhere => qr{\w,\s\w}, 'Еще тест прошел';
@unera
Copy link
Author

unera commented Sep 14, 2016

console log (old mojo):

1..6
ok 1 - require Mojolicious;
ok 2 - use Test::Mojo;
# тесты mojo
ok 3 - GET /ping
ok 4 - 200 OK
ok 5 - Запрос выполнен успешно
# другие тесты
ok 6 - Еще тест прошел

without #use open qw(:std :utf8);

1..6
ok 1 - require Mojolicious;
ok 2 - use Test::Mojo;
Wide character in print at /usr/share/perl/5.20/Test/Builder.pm line 1821, <DATA> line 2125.
# тесты mojo
ok 3 - GET /ping
ok 4 - 200 OK
Wide character in print at /usr/share/perl/5.20/Test/Builder.pm line 1821, <DATA> line 2125.
ok 5 - Запрос выполнен успешно
Wide character in print at /usr/share/perl/5.20/Test/Builder.pm line 1821, <DATA> line 2125.
# другие тесты
Wide character in print at /usr/share/perl/5.20/Test/Builder.pm line 1821, <DATA> line 2125.
ok 6 - Еще тест прошел

without use utf8

1..6
ok 1 - require Mojolicious;
ok 2 - use Test::Mojo;
# тесты mojo
ok 3 - GET /ping
ok 4 - 200 OK
ok 5 - Запрос выполнен успешно
# другие тесты
not ok 6 - Еще тест прошел
#   Failed test 'Еще тест прошел'
#   at test.t line 44.
#                   'Привет, медвед'
#     doesn't match '(?^:\w,\s\w)'
# Looks like you failed 1 test of 6.

@unera
Copy link
Author

unera commented Sep 14, 2016

current mojo (git version)

1..6
ok 1 - require Mojolicious;
ok 2 - use Test::Mojo;
# тесты mojo
ok 3 - GET /ping
ok 4 - 200 OK
ok 5 - ÐапÑÐ¾Ñ Ð²Ñполнен ÑÑпеÑно
# другие тесты
ok 6 - Еще тест прошел

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment