File: 07magic.t

package info (click to toggle)
libclone-fast-perl 0.96-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 344 kB
  • sloc: perl: 200; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 959 bytes parent folder | download
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
# $Id: 07magic.t,v 1.1 2006/07/14 03:10:13 thall Exp $

use strict;

use Clone::Fast qw( clone );
use Test::More tests => 3;

SKIP: {
  eval "use Data::Dumper";
  skip "Data::Dumper not installed", 1 if $@;

  SKIP: {
    eval "use Scalar::Util qw( weaken )";
    skip "Scalar::Util not installed", 1 if $@;
  
    my $x = { a => "worked\n" }; 
    my $y = $x;
    weaken($y);
    my $z = Clone::Fast::clone($x);
    is_deeply( $x, $z, "Cloned weak reference");
  }
}

SKIP: {
  eval "use Taint::Runtime qw(enable taint_env)";
  skip "Taint::Runtime not installed", 1 if $@;
  taint_env();
  my $x = "";
  for (keys %ENV)
  {
    $x = $ENV{$_};
    last if ( $x && length($x) > 0 );
  }
  my $y = Clone::Fast::clone($x);
  ## ok(Clone::Fast::clone($tainted), "Tainted input");
  is_deeply( $x, $y, "Tainted input");
}

# This would segfault in the past.
$_ = 'I really like to clone magic';
pos() = 0;
clone( $_ );
pass( "Cloned variable with pos() magic" );