File: 12-pipely-oneway.t

package info (click to toggle)
libio-pipely-perl 0.006-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 188 kB
  • sloc: perl: 698; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,415 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use warnings;
use strict;

use Test::More tests => 4;

BEGIN { use_ok 'IO::Pipely', 'pipely' };

### Test one-way pipe() pipe.

SKIP: {
  my ($uni_read, $uni_write) = pipely(type => 'pipe');
  skip "$^O does not support one-way pipe()", 1
    unless defined $uni_read and defined $uni_write;

  print $uni_write "whee pipe\n";
  my $uni_input = <$uni_read>; chomp $uni_input;
  ok($uni_input eq "whee pipe", "one-way pipe passed data unscathed");
}

### Test one-way socketpair() pipe.
SKIP: {
  my ($uni_read, $uni_write) = pipely(type => 'socketpair');

  skip "$^O does not support one-way socketpair()", 1
    unless defined $uni_read and defined $uni_write;

  print $uni_write "whee socketpair\n";
  my $uni_input = <$uni_read>; chomp $uni_input;
  ok(
    $uni_input eq 'whee socketpair',
    "one-way socketpair passed data unscathed"
  );
}

### Test one-way pair of inet sockets.
SKIP: {

  unless ($ENV{RUN_NETWORK_TESTS}) {
    skip 'RUN_NETWORK_TESTS environment variable is not true.', 1;
  }

  my ($uni_read, $uni_write) = pipely(type => 'inet');
  skip "$^O does not support one-way inet sockets.", 1
    unless defined $uni_read and defined $uni_write;

  print $uni_write "whee inet\n";
  my $uni_input = <$uni_read>; chomp $uni_input;
  ok(
    $uni_input eq 'whee inet',
    "one-way inet pipe passed data unscathed"
  );
}

exit 0;