App-SocialSKK

 view release on metacpan or  search on metacpan

inc/Net/Ping/External.pm  view on Meta::CPAN

# results of the system ping command.
sub _ping_win32 {
  my %args = @_;
  $args{timeout} *= 1000;    # Win32 ping timeout is specified in milliseconds
  #for each ping
  my $command = "ping -l $args{size} -n $args{count} -w $args{timeout} $args{host}";
  print "$command\n" if $DEBUG;
  my $result = `$command`;
  return 1 if $result =~ /time.*ms/;
  return 1 if $result =~ /TTL/;
  return 1 if $result =~ /is alive/; # ppt (from CPAN) ping
#  return 1 if $result !~ /\(100%/; # 100% packages lost
  return 0;
}

# Mac OS X 10.2 ping does not handle -w timeout now does it return a
# status code if it fails to ping (unless it cannot resolve the domain 
# name)
# Thanks to Peter N. Lewis for this one.
sub _ping_darwin {
   my %args = @_;

t/socialskk-plugin-eijiro.t  view on Meta::CPAN


sub startup : Test(startup) {
    my $self = shift;
       $self->module = App::SocialSKK::Plugin::Eijiro->new({
           ua => LWP::UserAgent->new,
       });
}

sub get_candidates : Tests {
    my $self = shift;
    my $network_is_alive = $self->ping('eowbeta.alc.co.jp');

 SKIP: {
        skip 'This test requires netword connection.' if !$network_is_alive;

        desc 'When get_candidates() called,' => sub {
            it 'for the word "ああ", some candidates should be returned.';
            ok scalar $self->module->get_candidates('ああ'), spec;

            it 'for empty string, no candidates should be returned.';
            ok !scalar $self->module->get_candidates(''), spec;
        };
    }
}

t/socialskk-plugin-socialime.t  view on Meta::CPAN


sub startup : Test(startup) {
    my $self = shift;
       $self->module = App::SocialSKK::Plugin::SocialIME->new({
           ua => LWP::UserAgent->new,
       });
}

sub get_candidates : Tests {
    my $self = shift;
    my $network_is_alive = $self->ping('www.social-ime.com');

 SKIP: {
        skip 'This test requires netword connection.' if !$network_is_alive;

        desc 'When get_candidates() called,' => sub {
            it 'for the word "ああ", some candidates should be returned.';
            ok scalar $self->module->get_candidates('ああ'), spec;

            it 'for empty string, no candidate should be returned.';
            ok !scalar $self->module->get_candidates(''), spec;
        };
    }
}

t/socialskk-plugin-wikipedia.t  view on Meta::CPAN


sub startup : Test(startup) {
    my $self = shift;
       $self->module = App::SocialSKK::Plugin::Wikipedia->new({
           ua => LWP::UserAgent->new,
       });
}

sub get_candidates : Tests {
    my $self = shift;
    my $network_is_alive = $self->ping('ja.wikipedia.org');

 SKIP: {
        skip 'This test requires netword connection.' if !$network_is_alive;

        desc 'When get_candidates() called,' => sub {
            it 'for the word "ああ", some candidates should be returned.';
            ok scalar $self->module->get_candidates('ああ'), spec;

            it 'for empty string, no candidates should be returned.';
            ok !scalar $self->module->get_candidates(''), spec;
        };
    }
}

t/socialskk.t  view on Meta::CPAN

    my $self = shift;

    desc 'When get_version() called,' => sub {
        it 'correct serverinfo string should be returned.';
        is $self->module->get_serverinfo, 'localhost:127.0.0.1: ', spec;
    };
}

sub get_candidates : Tests {
    my $self = shift;
    my $network_is_alive = $self->ping('www.social-ime.com') &&
                           $self->ping('ja.wikipedia.org');

 SKIP: {
        skip 'This test requires netword connection.' if !$network_is_alive;

        desc 'When get_candidates() called,' => sub {
            it 'for the word "ああ", some candidates should be returned.';
            like $self->module->get_candidates('ああ'), qr/^1.+/, spec;

            it 'for empty string, no candidate should be returned.';
            like $self->module->get_candidates(''), qr/^4/, spec;
        };
    }
}



( run in 1.160 second using v1.01-cache-2.11-cpan-df04353d9ac )