<commit_before># Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl uatraits.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';
use strict;
use Test::More ;
BEGIN { use_ok('uatraits') };

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $run_name = $0;
my $dir = $run_name;
$dir =~s/\/[^\/]*$//;
my $browser_path = $dir . "/../../data/browser.xml";

ok(-f $browser_path, "browser.xml found");
 
my $ok = 1;
my $obj;
eval {
    uatraits->new('');
    $ok = 0;
};

is( $ok , 1 , 'uatraits->new dies, when path to bowser.xml is invalid' );
is( $obj, undef, 'object not created');

eval {
    $obj = uatraits->new($browser_path);
};
ok( $obj , "uatraits object is created");
is( $@, '', "no errors");

subtest "detect" => sub {
    unless( $obj ){
        fail( 'cannot detect without an object');
        done_testing();
        return;
    }
    my $resp = $obj->detect('Mozilla/5.0 (Linux; U; Android 2.3; ru-ru; Desire_A8181 Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1');
    ok( $resp, "detect returns responce");
    is( ref( $resp) , 'HASH', "resp is hash");
    done_testing();
};

done_testing();
<commit_msg>make test work on older Test::More<commit_after># Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl uatraits.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';
use strict;
use Test::More ;
BEGIN { use_ok('uatraits') };

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $run_name = $0;
my $dir = $run_name;
$dir =~s/\/[^\/]*$//;
my $browser_path = $dir . "/../../data/browser.xml";

ok(-f $browser_path, "browser.xml found");
 
my $ok = 1;
my $obj;
eval {
    uatraits->new('');
    $ok = 0;
};

is( $ok , 1 , 'uatraits->new dies, when path to bowser.xml is invalid' );
is( $obj, undef, 'object not created');

eval {
    $obj = uatraits->new($browser_path);
};
ok( $obj , "uatraits object is created");
is( $@, '', "no errors");

#subtest "detect" => sub {
    unless( $obj ){
        fail( 'cannot detect without an object');
#        done_testing();
#        return;
    } else {
        my $resp = $obj->detect('Mozilla/5.0 (Linux; U; Android 2.3; ru-ru; Desire_A8181 Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1');
        ok( $resp, "detect returns responce");
        is( ref( $resp) , 'HASH', "resp is hash");
    }
#    done_testing();
#};

done_testing();

{'fraction_non_alphanumeric': 0.2065941774815854, 'fraction_numerical': 0.017537706068046298, 'mean_word_length': 3.519809825673534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6566403', 'n_tokens_mistral': 1038, 'n_tokens_neox': 993, 'n_words': 322}