~ubuntu-branches/ubuntu/maverick/libcapture-tiny-perl/maverick

« back to all changes in this revision

Viewing changes to t/10-stdout-string.t

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-05-23 04:44:25 UTC
  • Revision ID: james.westby@ubuntu.com-20090523044425-i3cuofbmt79rqq8e
Tags: upstream-0.06
ImportĀ upstreamĀ versionĀ 0.06

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2009 by David Golden. All rights reserved.
 
2
# Licensed under Apache License, Version 2.0 (the "License").
 
3
# You may not use this file except in compliance with the License.
 
4
# A copy of the License was distributed with this file or you may obtain a 
 
5
# copy of the License from http://www.apache.org/licenses/LICENSE-2.0
 
6
 
 
7
use strict;
 
8
use warnings;
 
9
use Test::More;
 
10
use t::lib::Utils qw/save_std restore_std next_fd/;
 
11
use t::lib::Cases qw/run_test/;
 
12
 
 
13
use Config;
 
14
my $no_fork = $^O ne 'MSWin32' && ! $Config{d_fork};
 
15
 
 
16
plan skip_all => "In memory files require Perl 5.8"
 
17
  if $] < 5.008;
 
18
 
 
19
plan 'no_plan';
 
20
 
 
21
my $builder = Test::More->builder;
 
22
binmode($builder->failure_output, ':utf8') if $] >= 5.008;
 
23
 
 
24
save_std(qw/stdout/);
 
25
ok( close STDOUT, "closed STDOUT" );
 
26
ok( open( STDOUT, ">", \(my $stdout_buf)), "reopened STDOUT to string" ); 
 
27
 
 
28
my $fd = next_fd;
 
29
 
 
30
run_test($_) for qw(
 
31
  capture
 
32
  capture_scalar
 
33
  capture_merged
 
34
);
 
35
 
 
36
if ( ! $no_fork ) {
 
37
  run_test($_) for qw(
 
38
    tee
 
39
    tee_scalar
 
40
    tee_merged
 
41
  );
 
42
}
 
43
 
 
44
is( next_fd, $fd, "no file descriptors leaked" );
 
45
restore_std(qw/stdout/);
 
46
 
 
47
exit 0;
 
48