~ubuntu-branches/ubuntu/saucy/libyaml-libyaml-perl/saucy-security

« back to all changes in this revision

Viewing changes to t/code.t

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-06-01 02:17:22 UTC
  • Revision ID: james.westby@ubuntu.com-20090601021722-8qlj45pmu8ffwzau
Tags: upstream-0.32
ImportĀ upstreamĀ versionĀ 0.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use t::TestYAMLTests tests => 3;
 
2
 
 
3
#-------------------------------------------------------------------------------
 
4
my $sub = sub { print "Hi.\n" };
 
5
 
 
6
my $yaml = <<'...';
 
7
--- !!perl/code '{ "DUMMY" }'
 
8
...
 
9
 
 
10
is Dump($sub), $yaml,
 
11
    "Dumping a code ref works produces DUMMY";
 
12
 
 
13
#-------------------------------------------------------------------------------
 
14
$sub = sub { print "Bye.\n" };
 
15
bless $sub, "Barry::White";
 
16
 
 
17
$yaml = <<'...';
 
18
--- !!perl/code:Barry::White |-
 
19
  {
 
20
      use warnings;
 
21
      use strict 'refs';
 
22
      print "Bye.\n";
 
23
  }
 
24
...
 
25
 
 
26
$YAML::XS::DumpCode = 1;
 
27
is Dump($sub), $yaml,
 
28
    "Dumping a blessed code ref works (with B::Deparse)";
 
29
 
 
30
#-------------------------------------------------------------------------------
 
31
$sub = sub { print "Bye.\n" };
 
32
bless $sub, "Barry::White";
 
33
 
 
34
$yaml = <<'...';
 
35
--- !!perl/code:Barry::White '{ "DUMMY" }'
 
36
...
 
37
 
 
38
$YAML::XS::DumpCode = 0;
 
39
is Dump($sub), $yaml,
 
40
    "Dumping a blessed code ref works (with DUMMY again)";
 
41