~ubuntu-branches/ubuntu/wily/libio-socket-ssl-perl/wily

« back to all changes in this revision

Viewing changes to t/readline.t

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2014-01-17 11:28:23 UTC
  • mfrom: (41.1.2 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140117112823-xemv5h0jdtms3oee
Tags: 1.965-1ubuntu1
* Resynchronize on Debian, remaining change
* Prefer the ipv6 alternatives for the recommendations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!perl -w
 
1
#!perl
2
2
# Before `make install' is performed this script should be runnable with
3
3
# `make test'. After `make install' it should work as `perl t/readline.t'
4
4
 
5
 
# This tests the behavior of readline with the variety of 
 
5
# This tests the behavior of readline with the variety of
6
6
# cases with $/:
7
7
# $/ undef - read all
8
8
# $/ ''    - read up to next nonempty line: .*?\n\n+
11
11
# scalar context - get first match
12
12
# array context  - get all matches
13
13
 
 
14
use strict;
 
15
use warnings;
14
16
use Net::SSLeay;
15
17
use Socket;
16
18
use IO::Socket::SSL;
17
 
use strict;
18
19
 
19
20
if ( grep { $^O =~m{$_} } qw( MacOS VOS vmesa riscos amigaos ) ) {
20
21
    print "1..0 # Skipped: fork not implemented on this platform\n";
25
26
push @tests, [
26
27
    "multi\nple\n\n1234567890line\n\n\n\nbla\n\nblubb\n\nblip",
27
28
    sub {
28
 
        my $c = shift;
 
29
        my $c = shift;
29
30
        local $/ = "\n\n";
30
31
        my $b;
31
32
        ($b=<$c>) eq "multi\nple\n\n" || die "LFLF failed ($b)";
43
44
push @tests, [
44
45
    "some\nstring\nwith\nsome\nlines\nwhatever",
45
46
    sub {
46
 
        my $c = shift;
 
47
        my $c = shift;
47
48
        local $/ = "\n";
48
49
        my $b;
49
50
        ($b=<$c>) eq "some\n" || die "LF failed ($b)";
55
56
push @tests, [
56
57
    "some\nstring\nwith\nsome\nlines\nwhatever",
57
58
    sub {
58
 
        my $c = shift;
 
59
        my $c = shift;
59
60
        local $/ = "\n";
60
61
        my @c = <$c>;
61
62
        die "LF @ failed: @c" unless $c[0] eq "some\n" &&
68
69
push @tests, [
69
70
    "some\nstring\nwith\nsome\nlines\nwhatever",
70
71
    sub {
71
 
        my $c = shift;
 
72
        my $c = shift;
72
73
        local $/;
73
74
        my @c = <$c>;
74
 
        die "undef @ failed: @c" unless 
 
75
        die "undef @ failed: @c" unless
75
76
            $c[0] eq "some\nstring\nwith\nsome\nlines\nwhatever"
76
77
            && @c == 1;
77
78
 
81
82
push @tests, [
82
83
    "1234567890",
83
84
    sub {
84
 
        my $c = shift;
 
85
        my $c = shift;
85
86
        local $/ = \2;
86
87
        my @c = <$c>;
87
 
        die "\\2 @ failed: @c" unless 
 
88
        die "\\2 @ failed: @c" unless
88
89
            $c[0] eq '12' && $c[1] eq '34' && $c[2] eq '56' &&
89
90
            $c[3] eq '78' && $c[4] eq '90' && @c == 5;
90
91
 
94
95
push @tests, [
95
96
    [ "bla\n","0","blubb\n","no newline" ],
96
97
    sub {
97
 
        my $c = shift;
 
98
        my $c = shift;
98
99
        my $l = <$c>;
99
100
        $l eq "bla\n" or die "'bla\\n' failed";
100
101
        $l = <$c>;
155
156
close($server);
156
157
my $testid = "Test00";
157
158
foreach my $test (@tests) {
158
 
    my $to_server = IO::Socket::SSL->new( $addr ) || do {
 
159
    my $to_server = IO::Socket::SSL->new(
 
160
        PeerAddr => $addr,
 
161
        SSL_verify_mode => 0 ) || do {
159
162
        notok( "connect failed: ".IO::Socket::SSL->errstr() );
160
163
        exit
161
164
    };