1# $Id: 07magic.t,v 1.8 2007/04/20 05:40:48 ray Exp $
2
3use strict;
4
5use Clone;
6use Test::More tests => 3;
7
8SKIP: {
9  eval "use Data::Dumper";
10  skip "Data::Dumper not installed", 1 if $@;
11
12  SKIP: {
13    eval "use Scalar::Util qw( weaken )";
14    skip "Scalar::Util not installed", 1 if $@;
15  
16    my $x = { a => "worked\n" }; 
17    my $y = $x;
18    weaken($y);
19    my $z = Clone::clone($x);
20    ok( Dumper($x) eq Dumper($z), "Cloned weak reference");
21  }
22
23  ## RT 21859: Clone segfault (isolated example)
24  SKIP: {
25    my $string = "HDDR-WD-250JS";
26    eval {
27      use utf8;
28      utf8::upgrade($string);
29    };
30    skip $@, 1 if $@;
31    $string = sprintf ('<<bg_color=%s>>%s<</bg_color>>%s',
32          '#EA0',
33          substr ($string, 0, 4),
34          substr ($string, 4),
35        );
36    my $z = Clone::clone($string);
37    ok( Dumper($string) eq Dumper($z), "Cloned magic utf8");
38  }
39}
40
41SKIP: {
42  eval "use Taint::Runtime qw(enable taint_env)";
43  skip "Taint::Runtime not installed", 1 if $@;
44  taint_env();
45  my $x = "";
46  for (keys %ENV)
47  {
48    $x = $ENV{$_};
49    last if ( $x && length($x) > 0 );
50  }
51  my $y = Clone::clone($x);
52  ## ok(Clone::clone($tainted), "Tainted input");
53  ok( Dumper($x) eq Dumper($y), "Tainted input");
54}
55
56